diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index 23af6f8..d2faf9a 100755
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -6,7 +6,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
@@ -77,7 +77,7 @@ my $ipvnum = 4;     # server IPv number (4 or 6)
 my $proto = 'ftp';  # default server protocol
 my $srcdir;         # directory where ftpserver.pl is located
 my $srvrname;       # server name for presentation purposes
-
+my $cwd_testno;     # test case numbers extracted from CWD command
 my $path   = '.';
 my $logdir = $path .'/log';
 
@@ -1158,7 +1158,10 @@ sub switch_directory_goto {
 sub switch_directory {
     my $target_dir = $_[0];
 
-    if($target_dir eq "/") {
+    if($target_dir =~ /^test-(\d+)/) {
+        $cwd_testno = $1;
+    }
+    elsif($target_dir eq "/") {
         $ftptargetdir = "/";
     }
     else {
@@ -1191,7 +1194,7 @@ sub PWD_ftp {
 }
 
 sub LIST_ftp {
-  #  print "150 ASCII data connection for /bin/ls (193.15.23.1,59196) (0 bytes)\r\n";
+    #  print "150 ASCII data connection for /bin/ls (193.15.23.1,59196) (0 bytes)\r\n";
 
 # this is a built-in fake-dir ;-)
 my @ftpdir=("total 20\r\n",
@@ -1226,12 +1229,26 @@ my @ftpdir=("total 20\r\n",
     }
 
     if($ftplistparserstate) {
-      @ftpdir = ftp_contentlist($ftptargetdir);
+        @ftpdir = ftp_contentlist($ftptargetdir);
     }
 
     logmsg "pass LIST data on data connection\n";
-    for(@ftpdir) {
-        senddata $_;
+
+    if($cwd_testno) {
+        loadtest("$srcdir/data/test$cwd_testno");
+
+        my @data = getpart("reply", "data");
+        for(@data) {
+            my $send = $_;
+            senddata $send;
+        }
+
+    }
+    else {
+        # old hard-coded style
+        for(@ftpdir) {
+            senddata $_;
+        }
     }
     close_dataconn(0);
     sendcontrol "226 ASCII transfer complete\r\n";
