diff --git a/test/haxe/src/TestClient.hx b/test/haxe/src/TestClient.hx
index 3c98e6a..3f9158e 100644
--- a/test/haxe/src/TestClient.hx
+++ b/test/haxe/src/TestClient.hx
@@ -43,758 +43,758 @@
 
 
 class TestResults {
-	private var successCnt : Int = 0;
-	private var errorCnt : Int = 0;
-	private var failedTests : String = "";
-	private var print_direct : Bool = false;
-	
-	public static var EXITCODE_SUCCESS            = 0x00;  // no errors bits set
-	//
-	public static var EXITCODE_FAILBIT_BASETYPES  = 0x01;
-	public static var EXITCODE_FAILBIT_STRUCTS    = 0x02;
-	public static var EXITCODE_FAILBIT_CONTAINERS = 0x04;
-	public static var EXITCODE_FAILBIT_EXCEPTIONS = 0x08;
-	//
-	public static var EXITCODE_ALL_FAILBITS 	  = 0x0F;
-	//
-	private var testsExecuted : Int = 0;
-	private var testsFailed : Int = 0;
-	private var currentTest : Int = 0;
+    private var successCnt : Int = 0;
+    private var errorCnt : Int = 0;
+    private var failedTests : String = "";
+    private var print_direct : Bool = false;
 
-	
-	public function new(direct : Bool) {
-		print_direct = direct;
-	}
-	
-	public function StartTestGroup( groupBit : Int) : Void {
-		currentTest = groupBit;
-		testsExecuted |= groupBit;
-	}
-	
-	public function Expect( expr : Bool, msg : String) : Void {
-		if ( expr) {
-			++successCnt;
-		} else {
-			++errorCnt;
-			testsFailed |= currentTest;
-			failedTests += "\n  " + msg;
-			if( print_direct) {
-				trace('FAIL: $msg');
-			}
-		}
-	}
+    public static var EXITCODE_SUCCESS            = 0x00;  // no errors bits set
+    //
+    public static var EXITCODE_FAILBIT_BASETYPES  = 0x01;
+    public static var EXITCODE_FAILBIT_STRUCTS    = 0x02;
+    public static var EXITCODE_FAILBIT_CONTAINERS = 0x04;
+    public static var EXITCODE_FAILBIT_EXCEPTIONS = 0x08;
+    //
+    public static var EXITCODE_ALL_FAILBITS       = 0x0F;
+    //
+    private var testsExecuted : Int = 0;
+    private var testsFailed : Int = 0;
+    private var currentTest : Int = 0;
 
-	public function CalculateExitCode() : Int {
-		var notExecuted : Int = EXITCODE_ALL_FAILBITS & (~testsExecuted);
-		return testsFailed | notExecuted;
-	}
 
-	public function PrintSummary() : Void {
-		var total = successCnt + errorCnt;
-		var sp = (100 * successCnt) / total;
-		var ep = (100 * errorCnt) / total;
-		
-		trace('===========================');
-		trace('Tests executed    $total');
-		trace('Tests succeeded   $successCnt ($sp%)');
-		trace('Tests failed      $errorCnt ($ep%)');
-		if ( errorCnt > 0)
-		{
-			trace('===========================');
-  			trace('FAILED TESTS: $failedTests');
-		}
-		trace('===========================');
-	}
+    public function new(direct : Bool) {
+        print_direct = direct;
+    }
+
+    public function StartTestGroup( groupBit : Int) : Void {
+        currentTest = groupBit;
+        testsExecuted |= groupBit;
+    }
+
+    public function Expect( expr : Bool, msg : String) : Void {
+        if ( expr) {
+            ++successCnt;
+        } else {
+            ++errorCnt;
+            testsFailed |= currentTest;
+            failedTests += "\n  " + msg;
+            if( print_direct) {
+                trace('FAIL: $msg');
+            }
+        }
+    }
+
+    public function CalculateExitCode() : Int {
+        var notExecuted : Int = EXITCODE_ALL_FAILBITS & (~testsExecuted);
+        return testsFailed | notExecuted;
+    }
+
+    public function PrintSummary() : Void {
+        var total = successCnt + errorCnt;
+        var sp = (100 * successCnt) / total;
+        var ep = (100 * errorCnt) / total;
+
+        trace('===========================');
+        trace('Tests executed    $total');
+        trace('Tests succeeded   $successCnt ($sp%)');
+        trace('Tests failed      $errorCnt ($ep%)');
+        if ( errorCnt > 0)
+        {
+            trace('===========================');
+              trace('FAILED TESTS: $failedTests');
+        }
+        trace('===========================');
+    }
 }
 
 
 class TestClient {
 
-	public static function Execute(args : Arguments) :  Void
-	{
-		var exitCode = 0xFF;
-		try
-		{
-			var difft = Timer.stamp();
-	
-			if( args.numThreads > 1) {
-				var threads = new List<Thread>();
-				for( test in 0 ... args.numThreads) {
-					threads.add( StartThread( args));
-				} 
-				exitCode = 0;
-				for( thread in threads) {
-					exitCode |= Thread.readMessage(true);
-				}
-			} else {
-				var rslt = new TestResults(true);
-				RunClient(args,rslt);
-				rslt.PrintSummary();
-				exitCode = rslt.CalculateExitCode();
-			}
+    public static function Execute(args : Arguments) :  Void
+    {
+        var exitCode = 0xFF;
+        try
+        {
+            var difft = Timer.stamp();
 
-			difft = Timer.stamp() - difft;
-			trace('total test time: $difft seconds');
-		}
-		catch (e : TException)
-		{
-			trace('$e');
-			exitCode = 0xFF;
-		}
-		catch (e : Dynamic)
-		{
-			trace('$e');
-			exitCode = 0xFF;
-		}
-	
-		#if sys
-		Sys.exit( exitCode);
-		#end
-	}
+            if( args.numThreads > 1) {
+                var threads = new List<Thread>();
+                for( test in 0 ... args.numThreads) {
+                    threads.add( StartThread( args));
+                }
+                exitCode = 0;
+                for( thread in threads) {
+                    exitCode |= Thread.readMessage(true);
+                }
+            } else {
+                var rslt = new TestResults(true);
+                RunClient(args,rslt);
+                rslt.PrintSummary();
+                exitCode = rslt.CalculateExitCode();
+            }
 
-	
-	private static function StartThread(args : Arguments) : Thread {
-		var thread = Thread.create(
-			function() : Void {
-				var rslt = new TestResults(false);
-				var main : Thread = Thread.readMessage(true);
-				try 
-				{
-					RunClient(args,rslt);
-				}
-				catch (e : TException)
-				{
-					rslt.Expect( false, '$e');
-					trace('$e');
-				}
-				catch (e : Dynamic)
-				{
-					rslt.Expect( false, '$e');
-					trace('$e');
-				}					
-				main.sendMessage( rslt.CalculateExitCode());
-			});
-		
-		thread.sendMessage(Thread.current());
-		return thread;
-	}
+            difft = Timer.stamp() - difft;
+            trace('total test time: $difft seconds');
+        }
+        catch (e : TException)
+        {
+            trace('$e');
+            exitCode = 0xFF;
+        }
+        catch (e : Dynamic)
+        {
+            trace('$e');
+            exitCode = 0xFF;
+        }
 
-	
-	public static function RunClient(args : Arguments, rslt : TestResults)
-	{
-		var transport : TTransport = null;
-		switch (args.transport)
-		{
-			case socket:
-				transport = new TSocket(args.host, args.port);
-			case http:
-				transport = new THttpClient(args.host);
-			default:
-				throw "Unhandled transport";
-		}
+        #if sys
+        Sys.exit( exitCode);
+        #end
+    }
 
-		// optional: layered transport
-		if ( args.framed) {
-			trace("- framed transport");
-			transport = new TFramedTransport(transport);
-		} 
-		if ( args.buffered) {
-			trace("- buffered transport");
-			throw "TBufferedTransport not implemented yet";
-			//transport = new TBufferedTransport(transport);
-		}
 
-		// protocol
-		var protocol : TProtocol = null;
-		switch( args.protocol)
-		{
-		case binary:
-			trace("- binary protocol");
-			protocol = new TBinaryProtocol(transport);
-		case json:
-			trace("- json protocol");
-			protocol = new TJSONProtocol(transport);
-		default:
-			throw "Unhandled protocol";
-		}
+    private static function StartThread(args : Arguments) : Thread {
+        var thread = Thread.create(
+            function() : Void {
+                var rslt = new TestResults(false);
+                var main : Thread = Thread.readMessage(true);
+                try
+                {
+                    RunClient(args,rslt);
+                }
+                catch (e : TException)
+                {
+                    rslt.Expect( false, '$e');
+                    trace('$e');
+                }
+                catch (e : Dynamic)
+                {
+                    rslt.Expect( false, '$e');
+                    trace('$e');
+                }
+                main.sendMessage( rslt.CalculateExitCode());
+            });
 
+        thread.sendMessage(Thread.current());
+        return thread;
+    }
 
-		// run the test code
-		HaxeBasicsTest( args, rslt);
-		for( i in 0 ... args.numIterations) {
-			ClientTest( transport, protocol, args, rslt);
-		}
-	}
 
+    public static function RunClient(args : Arguments, rslt : TestResults)
+    {
+        var transport : TTransport = null;
+        switch (args.transport)
+        {
+            case socket:
+                transport = new TSocket(args.host, args.port);
+            case http:
+                transport = new THttpClient(args.host);
+            default:
+                throw "Unhandled transport";
+        }
 
-	public static function HaxeBasicsTest( args : Arguments, rslt : TestResults) : Void
-	{
-		// We need to test a few basic things used in the ClientTest
-		// Anything else beyond this scope should go into /lib/haxe/ instead
-		rslt.StartTestGroup( 0);
-		
-		var map32 = new IntMap<Int32>();
-		var map64 = new Int64Map<Int32>();
+        // optional: layered transport
+        if ( args.framed) {
+            trace("- framed transport");
+            transport = new TFramedTransport(transport);
+        }
+        if ( args.buffered) {
+            trace("- buffered transport");
+            throw "TBufferedTransport not implemented yet";
+            //transport = new TBufferedTransport(transport);
+        }
 
-		rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #1");
-		rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #2");
-		rslt.Expect( map32.remove( 4711) == map64.remove( Int64.make(47,11)), "Int64Map<Int32> Test #3");
-		rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #4");
-		
-		map32.set( 42, 815);
-		map64.set( Int64.make(0,42), 815);
-		map32.set( -517, 23);
-		map64.set( Int64.make(-5,17), 23);
-		map32.set( 0, -123);
-		map64.set( Int64.make(0,0), -123);
+        // protocol
+        var protocol : TProtocol = null;
+        switch( args.protocol)
+        {
+        case binary:
+            trace("- binary protocol");
+            protocol = new TBinaryProtocol(transport);
+        case json:
+            trace("- json protocol");
+            protocol = new TJSONProtocol(transport);
+        default:
+            throw "Unhandled protocol";
+        }
 
-		rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #10");
-		rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #11");
-		rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #12");
-		rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #13");
-		rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #14");
-		rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #15");
-		rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #16");
-		rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #Int64.make(-5,17)");
-		rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #18");
-		rslt.Expect( map32.remove( 4711) == map64.remove( Int64.make(47,11)), "Int64Map<Int32> Test #19");
-		rslt.Expect( map32.remove( -517) == map64.remove( Int64.make(-5,17)), "Int64Map<Int32> Test #20");
-		rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #21");
-		rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #22");
-		rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #23");
-		rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #24");
-		rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #25");
-		rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #26");
-		rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #27");
-		rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #28");
 
-		map32.set( 42, 1);
-		map64.set( Int64.make(0,42), 1);
-		map32.set( -517, -2);
-		map64.set( Int64.make(-5,17), -2);
-		map32.set( 0, 3);
-		map64.set( Int64.make(0,0), 3);
+        // run the test code
+        HaxeBasicsTest( args, rslt);
+        for( i in 0 ... args.numIterations) {
+            ClientTest( transport, protocol, args, rslt);
+        }
+    }
 
-		var c32 = 0;
-		for (key in map32.keys()) {
-			++c32;
-		}
-		var c64 = 0;
-		for (key in map64.keys()) {
-			++c64;
-		}
-		rslt.Expect( c32 == c64, "Int64Map<Int32> Test #30");
 
-		var s32 = map32.toString();
-		var s64 = map64.toString();
-		trace("Int64Map<Int32>.toString(): " + ' ("$s32" == "$s64")');
+    public static function HaxeBasicsTest( args : Arguments, rslt : TestResults) : Void
+    {
+        // We need to test a few basic things used in the ClientTest
+        // Anything else beyond this scope should go into /lib/haxe/ instead
+        rslt.StartTestGroup( 0);
 
-		map32.remove( 42);
-		map64.remove( Int64.make(0,42));
-		map32.remove( -517);
-		map64.remove( Int64.make(-5,17));
-		map32.remove( 0);
-		map64.remove( Int64.make(0,0));
-		
-		rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #90");
-		rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #91");
-		rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #92");
-		rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #93");
-		rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #94");
-		rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #95");
-		rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #96");
-		rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #97");
-		rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #98");
-	}
+        var map32 = new IntMap<Int32>();
+        var map64 = new Int64Map<Int32>();
 
+        rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #1");
+        rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #2");
+        rslt.Expect( map32.remove( 4711) == map64.remove( Int64.make(47,11)), "Int64Map<Int32> Test #3");
+        rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #4");
 
-	public static function ClientTest( transport : TTransport, protocol : TProtocol, 
-									   args : Arguments, rslt : TestResults) : Void
-	{
-		var client = new ThriftTestImpl(protocol,protocol);
-		try
-		{
-			if (!transport.isOpen())
-			{
-				transport.open();
-			}
-		}
-		catch (e : TException)
-		{
-			trace('$e');
-			return;
-		}
-		catch (e : Dynamic)
-		{
-			trace('$e');
-			return;
-		}
+        map32.set( 42, 815);
+        map64.set( Int64.make(0,42), 815);
+        map32.set( -517, 23);
+        map64.set( Int64.make(-5,17), 23);
+        map32.set( 0, -123);
+        map64.set( Int64.make(0,0), -123);
 
-		var start = Date.now();
+        rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #10");
+        rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #11");
+        rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #12");
+        rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #13");
+        rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #14");
+        rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #15");
+        rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #16");
+        rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #Int64.make(-5,17)");
+        rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #18");
+        rslt.Expect( map32.remove( 4711) == map64.remove( Int64.make(47,11)), "Int64Map<Int32> Test #19");
+        rslt.Expect( map32.remove( -517) == map64.remove( Int64.make(-5,17)), "Int64Map<Int32> Test #20");
+        rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #21");
+        rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #22");
+        rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #23");
+        rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #24");
+        rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #25");
+        rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #26");
+        rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #27");
+        rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #28");
 
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_EXCEPTIONS);
-	
-		// if arg == "Xception" throw Xception with errorCode = 1001 and message = arg
-		trace('testException("Xception")');
-		try {
-			client.testException("Xception");
-			rslt.Expect( false, 'testException("Xception") should throw');
-		}
-		catch (e : Xception)
-		{
-			rslt.Expect( e.message == "Xception", 'testException("Xception")  -  e.message == "Xception"');
-			rslt.Expect( e.errorCode == 1001, 'testException("Xception")  -  e.errorCode == 1001');
-		}
-		catch (e : Dynamic)
-		{
-			rslt.Expect( false, 'testException("Xception")  -  $e');
-		} 
-	
-		// if arg == "TException" throw TException
-		trace('testException("TException")');
-		try {
-			client.testException("TException");
-			rslt.Expect( false, 'testException("TException") should throw');
-		}
-		catch (e : TException)
-		{
-			rslt.Expect( true, 'testException("TException")  -  $e');
-		}
-		catch (e : Dynamic)
-		{
-			rslt.Expect( false, 'testException("TException")  -  $e');
-		} 
-	
-		// else do not throw anything
-		trace('testException("bla")');
-		try {
-			client.testException("bla");
-			rslt.Expect( true, 'testException("bla") should not throw');
-		}
-		catch (e : Dynamic)
-		{
-			rslt.Expect( false, 'testException("bla")  -  $e');
-		} 
-			
-		
+        map32.set( 42, 1);
+        map64.set( Int64.make(0,42), 1);
+        map32.set( -517, -2);
+        map64.set( Int64.make(-5,17), -2);
+        map32.set( 0, 3);
+        map64.set( Int64.make(0,0), 3);
 
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_BASETYPES);
-		
-		trace('testVoid()');
-		client.testVoid();
-		trace(' = void');
-		rslt.Expect(true,"testVoid()");  // bump counter
+        var c32 = 0;
+        for (key in map32.keys()) {
+            ++c32;
+        }
+        var c64 = 0;
+        for (key in map64.keys()) {
+            ++c64;
+        }
+        rslt.Expect( c32 == c64, "Int64Map<Int32> Test #30");
 
-		trace('testString("Test")');
-		var s = client.testString("Test");
-		trace(' = "$s"');
-		rslt.Expect(s == "Test", '$s == "Test"');
+        var s32 = map32.toString();
+        var s64 = map64.toString();
+        trace("Int64Map<Int32>.toString(): " + ' ("$s32" == "$s64")');
 
-		trace('testByte(1)');
-		var i8 = client.testByte(1);
-		trace(' = $i8');
-		rslt.Expect(i8 == 1, '$i8 == 1');
+        map32.remove( 42);
+        map64.remove( Int64.make(0,42));
+        map32.remove( -517);
+        map64.remove( Int64.make(-5,17));
+        map32.remove( 0);
+        map64.remove( Int64.make(0,0));
 
-		trace('testI32(-1)');
-		var i32 = client.testI32(-1);
-		trace(' = $i32');
-		rslt.Expect(i32 == -1, '$i32 == -1');
+        rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #90");
+        rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #91");
+        rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #92");
+        rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #93");
+        rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #94");
+        rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #95");
+        rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #96");
+        rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #97");
+        rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #98");
+    }
 
-		trace('testI64(-34359738368)');
-		var i64 = client.testI64( Int64.make( 0xFFFFFFF8, 0x00000000)); // -34359738368
-		trace(' = $i64');
-		rslt.Expect( Int64.compare( i64, Int64.make( 0xFFFFFFF8, 0x00000000)) == 0, 
-		             Int64.toStr(i64) +" == "+Int64.toStr(Int64.make( 0xFFFFFFF8, 0x00000000)));
 
-		// edge case: the largest negative Int64 has no positive Int64 equivalent
-		trace('testI64(-9223372036854775808)');
-		i64 = client.testI64( Int64.make( 0x80000000, 0x00000000)); // -9223372036854775808
-		trace(' = $i64');
-		rslt.Expect( Int64.compare( i64, Int64.make( 0x80000000, 0x00000000)) == 0, 
-		             Int64.toStr(i64) +" == "+Int64.toStr(Int64.make( 0x80000000, 0x00000000)));
+    public static function ClientTest( transport : TTransport, protocol : TProtocol,
+                                       args : Arguments, rslt : TestResults) : Void
+    {
+        var client = new ThriftTestImpl(protocol,protocol);
+        try
+        {
+            if (!transport.isOpen())
+            {
+                transport.open();
+            }
+        }
+        catch (e : TException)
+        {
+            trace('$e');
+            return;
+        }
+        catch (e : Dynamic)
+        {
+            trace('$e');
+            return;
+        }
 
-		trace('testDouble(5.325098235)');
-		var dub = client.testDouble(5.325098235);
-		trace(' = $dub');
-		rslt.Expect(dub == 5.325098235, '$dub == 5.325098235');
+        var start = Date.now();
+
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_EXCEPTIONS);
+
+        // if arg == "Xception" throw Xception with errorCode = 1001 and message = arg
+        trace('testException("Xception")');
+        try {
+            client.testException("Xception");
+            rslt.Expect( false, 'testException("Xception") should throw');
+        }
+        catch (e : Xception)
+        {
+            rslt.Expect( e.message == "Xception", 'testException("Xception")  -  e.message == "Xception"');
+            rslt.Expect( e.errorCode == 1001, 'testException("Xception")  -  e.errorCode == 1001');
+        }
+        catch (e : Dynamic)
+        {
+            rslt.Expect( false, 'testException("Xception")  -  $e');
+        }
+
+        // if arg == "TException" throw TException
+        trace('testException("TException")');
+        try {
+            client.testException("TException");
+            rslt.Expect( false, 'testException("TException") should throw');
+        }
+        catch (e : TException)
+        {
+            rslt.Expect( true, 'testException("TException")  -  $e');
+        }
+        catch (e : Dynamic)
+        {
+            rslt.Expect( false, 'testException("TException")  -  $e');
+        }
+
+        // else do not throw anything
+        trace('testException("bla")');
+        try {
+            client.testException("bla");
+            rslt.Expect( true, 'testException("bla") should not throw');
+        }
+        catch (e : Dynamic)
+        {
+            rslt.Expect( false, 'testException("bla")  -  $e');
+        }
+
+
+
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_BASETYPES);
+
+        trace('testVoid()');
+        client.testVoid();
+        trace(' = void');
+        rslt.Expect(true,"testVoid()");  // bump counter
+
+        trace('testString("Test")');
+        var s = client.testString("Test");
+        trace(' = "$s"');
+        rslt.Expect(s == "Test", '$s == "Test"');
+
+        trace('testByte(1)');
+        var i8 = client.testByte(1);
+        trace(' = $i8');
+        rslt.Expect(i8 == 1, '$i8 == 1');
+
+        trace('testI32(-1)');
+        var i32 = client.testI32(-1);
+        trace(' = $i32');
+        rslt.Expect(i32 == -1, '$i32 == -1');
+
+        trace('testI64(-34359738368)');
+        var i64 = client.testI64( Int64.make( 0xFFFFFFF8, 0x00000000)); // -34359738368
+        trace(' = $i64');
+        rslt.Expect( Int64.compare( i64, Int64.make( 0xFFFFFFF8, 0x00000000)) == 0,
+                     Int64.toStr(i64) +" == "+Int64.toStr(Int64.make( 0xFFFFFFF8, 0x00000000)));
+
+        // edge case: the largest negative Int64 has no positive Int64 equivalent
+        trace('testI64(-9223372036854775808)');
+        i64 = client.testI64( Int64.make( 0x80000000, 0x00000000)); // -9223372036854775808
+        trace(' = $i64');
+        rslt.Expect( Int64.compare( i64, Int64.make( 0x80000000, 0x00000000)) == 0,
+                     Int64.toStr(i64) +" == "+Int64.toStr(Int64.make( 0x80000000, 0x00000000)));
+
+        trace('testDouble(5.325098235)');
+        var dub = client.testDouble(5.325098235);
+        trace(' = $dub');
+        rslt.Expect(dub == 5.325098235, '$dub == 5.325098235');
+
+
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_STRUCTS);
+
+        trace('testStruct({"Zero", 1, -3, -5})');
+        var o = new Xtruct();
+        o.string_thing = "Zero";
+        o.byte_thing = 1;
+        o.i32_thing = -3;
+        o.i64_thing = Int64.make(0,-5);
+        var i = client.testStruct(o);
+        trace(' = {"' + i.string_thing + '", ' + i.byte_thing +', '
+                      + i.i32_thing +', '+ Int64.toStr(i.i64_thing) + '}');
+        rslt.Expect( i.string_thing == o.string_thing, "i.string_thing == o.string_thing");
+        rslt.Expect( i.byte_thing == o.byte_thing, "i.byte_thing == o.byte_thing");
+        rslt.Expect( i.i32_thing == o.i32_thing, "i.i64_thing == o.i64_thing");
+        rslt.Expect( i.i32_thing == o.i32_thing, "i.i64_thing == o.i64_thing");
+
+        trace('testNest({1, {\"Zero\", 1, -3, -5}, 5})');
+        var o2 = new Xtruct2();
+        o2.byte_thing = 1;
+        o2.struct_thing = o;
+        o2.i32_thing = 5;
+        var i2 = client.testNest(o2);
+        i = i2.struct_thing;
+        trace(" = {" + i2.byte_thing + ", {\"" + i.string_thing + "\", "
+              + i.byte_thing + ", " + i.i32_thing + ", " + Int64.toStr(i.i64_thing) + "}, "
+              + i2.i32_thing + "}");
+        rslt.Expect( i2.byte_thing == o2.byte_thing, "i2.byte_thing == o2.byte_thing");
+        rslt.Expect( i2.i32_thing == o2.i32_thing, "i2.i32_thing == o2.i32_thing");
+        rslt.Expect( i.string_thing == o.string_thing, "i.string_thing == o.string_thing");
+        rslt.Expect( i.byte_thing == o.byte_thing, "i.byte_thing == o.byte_thing");
+        rslt.Expect( i.i32_thing == o.i32_thing, "i.i32_thing == o.i32_thing");
+        rslt.Expect( Int64.compare( i.i64_thing, o.i64_thing) == 0, "i.i64_thing == o.i64_thing");
+
+
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_CONTAINERS);
+
+        var mapout = new IntMap< haxe.Int32>();
+        for ( j in 0 ... 5)
+        {
+            mapout.set(j, j - 10);
+        }
+        trace("testMap({");
+        var first : Bool = true;
+        for( key in mapout.keys())
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                trace(", ");
+            }
+            trace(key + " => " + mapout.get(key));
+        }
+        trace("})");
 
-		
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_STRUCTS);
-		
-		trace('testStruct({"Zero", 1, -3, -5})');
-		var o = new Xtruct();
-		o.string_thing = "Zero";
-		o.byte_thing = 1;
-		o.i32_thing = -3;
-		o.i64_thing = Int64.make(0,-5);
-		var i = client.testStruct(o);
-		trace(' = {"' + i.string_thing + '", ' + i.byte_thing +', ' 
-					  + i.i32_thing +', '+ Int64.toStr(i.i64_thing) + '}');
-		rslt.Expect( i.string_thing == o.string_thing, "i.string_thing == o.string_thing");
-		rslt.Expect( i.byte_thing == o.byte_thing, "i.byte_thing == o.byte_thing");
-		rslt.Expect( i.i32_thing == o.i32_thing, "i.i64_thing == o.i64_thing");
-		rslt.Expect( i.i32_thing == o.i32_thing, "i.i64_thing == o.i64_thing");
+        var mapin = client.testMap(mapout);
 
-		trace('testNest({1, {\"Zero\", 1, -3, -5}, 5})');
-		var o2 = new Xtruct2();
-		o2.byte_thing = 1;
-		o2.struct_thing = o;
-		o2.i32_thing = 5;
-		var i2 = client.testNest(o2);
-		i = i2.struct_thing;
-		trace(" = {" + i2.byte_thing + ", {\"" + i.string_thing + "\", " 
-			  + i.byte_thing + ", " + i.i32_thing + ", " + Int64.toStr(i.i64_thing) + "}, " 
-			  + i2.i32_thing + "}");
-		rslt.Expect( i2.byte_thing == o2.byte_thing, "i2.byte_thing == o2.byte_thing");
-		rslt.Expect( i2.i32_thing == o2.i32_thing, "i2.i32_thing == o2.i32_thing");
-		rslt.Expect( i.string_thing == o.string_thing, "i.string_thing == o.string_thing");
-		rslt.Expect( i.byte_thing == o.byte_thing, "i.byte_thing == o.byte_thing");
-		rslt.Expect( i.i32_thing == o.i32_thing, "i.i32_thing == o.i32_thing");
-		rslt.Expect( Int64.compare( i.i64_thing, o.i64_thing) == 0, "i.i64_thing == o.i64_thing");
+        trace(" = {");
+        first = true;
+        for( key in mapin.keys())
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                trace(", ");
+            }
+            trace(key + " => " + mapin.get(key));
+            rslt.Expect( mapin.get(key) == mapout.get(key), ' mapin.get($key) == mapout.get($key)');
+        }
+        trace("}");
+        for( key in mapout.keys())
+        {
+            rslt.Expect(mapin.exists(key), 'mapin.exists($key)');
+        }
 
-		
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_CONTAINERS);
-		
-		var mapout = new IntMap< haxe.Int32>();
-		for ( j in 0 ... 5)
-		{
-			mapout.set(j, j - 10);
-		}
-		trace("testMap({");
-		var first : Bool = true;
-		for( key in mapout.keys())
-		{
-			if (first)
-			{
-				first = false;
-			}
-			else
-			{
-				trace(", ");
-			}
-			trace(key + " => " + mapout.get(key));
-		}
-		trace("})");
+        var listout = new List<Int>();
+        for (j in -2 ... 3)
+        {
+            listout.add(j);
+        }
+        trace("testList({");
+        first = true;
+        for( j in listout)
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                trace(", ");
+            }
+            trace(j);
+        }
+        trace("})");
 
-		var mapin = client.testMap(mapout);
+        var listin = client.testList(listout);
 
-		trace(" = {");
-		first = true;
-		for( key in mapin.keys())
-		{
-			if (first)
-			{
-				first = false;
-			}
-			else
-			{
-				trace(", ");
-			}
-			trace(key + " => " + mapin.get(key));
-			rslt.Expect( mapin.get(key) == mapout.get(key), ' mapin.get($key) == mapout.get($key)');
-		}
-		trace("}");
-		for( key in mapout.keys())
-		{
-			rslt.Expect(mapin.exists(key), 'mapin.exists($key)');
-		}
+        trace(" = {");
+        first = true;
+        for( j in listin)
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                trace(", ");
+            }
+            trace(j);
+        }
+        trace("}");
 
-		var listout = new List<Int>();
-		for (j in -2 ... 3)
-		{
-			listout.add(j);
-		}
-		trace("testList({");
-		first = true;
-		for( j in listout)
-		{
-			if (first)
-			{
-				first = false;
-			}
-			else
-			{
-				trace(", ");
-			}
-			trace(j);
-		}
-		trace("})");
+        rslt.Expect(listin.length == listout.length, "listin.length == listout.length");
+        var literout = listout.iterator();
+        var literin = listin.iterator();
+        while( literin.hasNext()) {
+            rslt.Expect(literin.next() == literout.next(), "literin[i] == literout[i]");
+        }
 
-		var listin = client.testList(listout);
+        //set
+        var setout = new IntSet();
+        for (j in -2 ... 3)
+        {
+            setout.add(j);
+        }
+        trace("testSet({");
+        first = true;
+        for( j in setout)
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                trace(", ");
+            }
+            trace(j);
+        }
+        trace("})");
 
-		trace(" = {");
-		first = true;
-		for( j in listin)
-		{
-			if (first)
-			{
-				first = false;
-			}
-			else
-			{
-				trace(", ");
-			}
-			trace(j);
-		}
-		trace("}");
+        var setin = client.testSet(setout);
 
-		rslt.Expect(listin.length == listout.length, "listin.length == listout.length");
-		var literout = listout.iterator();
-		var literin = listin.iterator();
-		while( literin.hasNext()) {
-			rslt.Expect(literin.next() == literout.next(), "literin[i] == literout[i]");
-		}
-	
-		//set
-		var setout = new IntSet();
-		for (j in -2 ... 3)
-		{
-			setout.add(j);
-		}
-		trace("testSet({");
-		first = true;
-		for( j in setout)
-		{
-			if (first)
-			{
-				first = false;
-			}
-			else
-			{
-				trace(", ");
-			}
-			trace(j);
-		}
-		trace("})");
+        trace(" = {");
+        first = true;
+        for( j in setin)
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                trace(", ");
+            }
+            trace(j);
+            rslt.Expect(setout.contains(j), 'setout.contains($j)');
+        }
+        trace("}");
+        rslt.Expect(setin.size == setout.size, "setin.length == setout.length");
 
-		var setin = client.testSet(setout);
 
-		trace(" = {");
-		first = true;
-		for( j in setin)
-		{
-			if (first)
-			{
-				first = false;
-			}
-			else
-			{
-				trace(", ");
-			}
-			trace(j);
-			rslt.Expect(setout.contains(j), 'setout.contains($j)');
-		}
-		trace("}");
-		rslt.Expect(setin.size == setout.size, "setin.length == setout.length");
-	
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_BASETYPES);
 
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_BASETYPES);
+        trace("testEnum(ONE)");
+        var ret = client.testEnum(Numberz.ONE);
+        trace(" = " + ret);
+        rslt.Expect(ret == Numberz.ONE, '$ret == Numberz.ONE');
 
-		trace("testEnum(ONE)");
-		var ret = client.testEnum(Numberz.ONE);
-		trace(" = " + ret);
-		rslt.Expect(ret == Numberz.ONE, '$ret == Numberz.ONE');
+        trace("testEnum(TWO)");
+        ret = client.testEnum(Numberz.TWO);
+        trace(" = " + ret);
+        rslt.Expect(ret == Numberz.TWO, '$ret == Numberz.TWO');
 
-		trace("testEnum(TWO)");
-		ret = client.testEnum(Numberz.TWO);
-		trace(" = " + ret);
-		rslt.Expect(ret == Numberz.TWO, '$ret == Numberz.TWO');
+        trace("testEnum(THREE)");
+        ret = client.testEnum(Numberz.THREE);
+        trace(" = " + ret);
+        rslt.Expect(ret == Numberz.THREE, '$ret == Numberz.THREE');
 
-		trace("testEnum(THREE)");
-		ret = client.testEnum(Numberz.THREE);
-		trace(" = " + ret);
-		rslt.Expect(ret == Numberz.THREE, '$ret == Numberz.THREE');
+        trace("testEnum(FIVE)");
+        ret = client.testEnum(Numberz.FIVE);
+        trace(" = " + ret);
+        rslt.Expect(ret == Numberz.FIVE, '$ret == Numberz.FIVE');
 
-		trace("testEnum(FIVE)");
-		ret = client.testEnum(Numberz.FIVE);
-		trace(" = " + ret);
-		rslt.Expect(ret == Numberz.FIVE, '$ret == Numberz.FIVE');
+        trace("testEnum(EIGHT)");
+        ret = client.testEnum(Numberz.EIGHT);
+        trace(" = " + ret);
+        rslt.Expect(ret == Numberz.EIGHT, '$ret == Numberz.EIGHT');
 
-		trace("testEnum(EIGHT)");
-		ret = client.testEnum(Numberz.EIGHT);
-		trace(" = " + ret);
-		rslt.Expect(ret == Numberz.EIGHT, '$ret == Numberz.EIGHT');
+        trace("testTypedef(309858235082523)");
+        var uid = client.testTypedef( Int64.make( 0x119D0, 0x7E08671B));  // 309858235082523
+        trace(" = " + uid);
+        rslt.Expect( Int64.compare( uid, Int64.make( 0x119D0, 0x7E08671B)) == 0,
+                     Int64.toStr(uid)+" == "+Int64.toStr(Int64.make( 0x119D0, 0x7E08671B)));
 
-		trace("testTypedef(309858235082523)");
-		var uid = client.testTypedef( Int64.make( 0x119D0, 0x7E08671B));  // 309858235082523
-		trace(" = " + uid);
-		rslt.Expect( Int64.compare( uid, Int64.make( 0x119D0, 0x7E08671B)) == 0,
-		             Int64.toStr(uid)+" == "+Int64.toStr(Int64.make( 0x119D0, 0x7E08671B)));
 
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_CONTAINERS);
 
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_CONTAINERS);
+        trace("testMapMap(1)");
+        var mm = client.testMapMap(1);
+        trace(" = {");
+        for( key in mm.keys())
+        {
+            trace(key + " => {");
+            var m2 = mm.get(key);
+            for( k2 in m2.keys())
+            {
+                trace(k2 + " => " + m2.get(k2) + ", ");
+            }
+            trace("}, ");
+        }
+        trace("}");
 
-		trace("testMapMap(1)");
-		var mm = client.testMapMap(1);
-		trace(" = {");
-		for( key in mm.keys())
-		{
-			trace(key + " => {");
-			var m2 = mm.get(key);
-			for( k2 in m2.keys())
-			{
-				trace(k2 + " => " + m2.get(k2) + ", ");
-			}
-			trace("}, ");
-		}
-		trace("}");
+        var pos = mm.get(4);
+        var neg = mm.get(-4);
+        rslt.Expect( (pos != null) && (neg != null), "(pos != null) && (neg != null)");
+        for (i in 0 ... 5) {
+            rslt.Expect( pos.get(i) == i, 'pos.get($i) == $i');
+            rslt.Expect( neg.get(-i) == -i, 'neg.get(-$i) == -$i');
+         }
 
-		var pos = mm.get(4);
-		var neg = mm.get(-4);
-		rslt.Expect( (pos != null) && (neg != null), "(pos != null) && (neg != null)");
-		for (i in 0 ... 5) {
-			rslt.Expect( pos.get(i) == i, 'pos.get($i) == $i');
-			rslt.Expect( neg.get(-i) == -i, 'neg.get(-$i) == -$i');
-	 	}
 
-			
-		rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_STRUCTS);
+        rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_STRUCTS);
 
-		var insane = new Insanity();
-		insane.userMap = new IntMap< Int64>();
-		insane.userMap.set( Numberz.FIVE, Int64.make(0,5000));
-		var truck = new Xtruct();
-		truck.string_thing = "Truck";
-		truck.byte_thing = 8;
-		truck.i32_thing = 8;
-		truck.i64_thing = Int64.make(0,8);
-		insane.xtructs = new List<Xtruct>();
-		insane.xtructs.add(truck);
-		trace("testInsanity()");
-		var whoa = client.testInsanity(insane);
-		trace(" = {");
-		for( key in whoa.keys())
-		{
-			var val = whoa.get(key);
-			trace(key + " => {");
+        var insane = new Insanity();
+        insane.userMap = new IntMap< Int64>();
+        insane.userMap.set( Numberz.FIVE, Int64.make(0,5000));
+        var truck = new Xtruct();
+        truck.string_thing = "Truck";
+        truck.byte_thing = 8;
+        truck.i32_thing = 8;
+        truck.i64_thing = Int64.make(0,8);
+        insane.xtructs = new List<Xtruct>();
+        insane.xtructs.add(truck);
+        trace("testInsanity()");
+        var whoa = client.testInsanity(insane);
+        trace(" = {");
+        for( key in whoa.keys())
+        {
+            var val = whoa.get(key);
+            trace(key + " => {");
 
-			for( k2 in val.keys())
-			{
-				var v2 = val.get(k2);
+            for( k2 in val.keys())
+            {
+                var v2 = val.get(k2);
 
-				trace(k2 + " => {");
-				var userMap = v2.userMap;
+                trace(k2 + " => {");
+                var userMap = v2.userMap;
 
-				trace("{");
-				if (userMap != null)
-				{
-					for( k3 in userMap.keys())
-					{
-						trace(k3 + " => " + userMap.get(k3) + ", ");
-					}
-				}
-				else
-				{
-					trace("null");
-				}
-				trace("}, ");
+                trace("{");
+                if (userMap != null)
+                {
+                    for( k3 in userMap.keys())
+                    {
+                        trace(k3 + " => " + userMap.get(k3) + ", ");
+                    }
+                }
+                else
+                {
+                    trace("null");
+                }
+                trace("}, ");
 
-				var xtructs = v2.xtructs;
+                var xtructs = v2.xtructs;
 
-				trace("{");
-				if (xtructs != null)
-				{
-					for( x in xtructs)
-					{
-						trace("{\"" + x.string_thing + "\", " 
-							  + x.byte_thing + ", " + x.i32_thing + ", " 
-							  + x.i32_thing + "}, ");
-					}
-				}
-				else
-				{
-					trace("null");
-				}
-				trace("}");
+                trace("{");
+                if (xtructs != null)
+                {
+                    for( x in xtructs)
+                    {
+                        trace("{\"" + x.string_thing + "\", "
+                              + x.byte_thing + ", " + x.i32_thing + ", "
+                              + x.i32_thing + "}, ");
+                    }
+                }
+                else
+                {
+                    trace("null");
+                }
+                trace("}");
 
-				trace("}, ");
-			}
-			trace("}, ");
-		}
-		trace("}");
+                trace("}, ");
+            }
+            trace("}, ");
+        }
+        trace("}");
 
 
-		var first_map = whoa.get(Int64.make(0,1));
-		var second_map = whoa.get(Int64.make(0,2));
-		rslt.Expect( (first_map != null) && (second_map != null), "(first_map != null) && (second_map != null)");
-		if ((first_map != null) && (second_map != null))
-		{
-			var crazy2 = first_map.get(Numberz.TWO);
-			var crazy3 = first_map.get(Numberz.THREE);
-			var looney = second_map.get(Numberz.SIX);
-			rslt.Expect( (crazy2 != null) && (crazy3 != null) && (looney != null), 
-						"(crazy2 != null) && (crazy3 != null) && (looney != null)");
+        var first_map = whoa.get(Int64.make(0,1));
+        var second_map = whoa.get(Int64.make(0,2));
+        rslt.Expect( (first_map != null) && (second_map != null), "(first_map != null) && (second_map != null)");
+        if ((first_map != null) && (second_map != null))
+        {
+            var crazy2 = first_map.get(Numberz.TWO);
+            var crazy3 = first_map.get(Numberz.THREE);
+            var looney = second_map.get(Numberz.SIX);
+            rslt.Expect( (crazy2 != null) && (crazy3 != null) && (looney != null),
+                        "(crazy2 != null) && (crazy3 != null) && (looney != null)");
 
-			rslt.Expect( Int64.compare( crazy2.userMap.get(Numberz.EIGHT), Int64.make(0,8)) == 0, 
-						"crazy2.UserMap.get(Numberz.EIGHT) == 8");
-			rslt.Expect( Int64.compare( crazy3.userMap.get(Numberz.EIGHT), Int64.make(0,8)) == 0, 
-						"crazy3.UserMap.get(Numberz.EIGHT) == 8");
-			rslt.Expect( Int64.compare( crazy2.userMap.get(Numberz.FIVE), Int64.make(0,5)) == 0, 
-						"crazy2.UserMap.get(Numberz.FIVE) == 5");
-			rslt.Expect( Int64.compare( crazy3.userMap.get(Numberz.FIVE), Int64.make(0,5)) == 0, 
-						"crazy3.UserMap.get(Numberz.FIVE) == 5");
+            rslt.Expect( Int64.compare( crazy2.userMap.get(Numberz.EIGHT), Int64.make(0,8)) == 0,
+                        "crazy2.UserMap.get(Numberz.EIGHT) == 8");
+            rslt.Expect( Int64.compare( crazy3.userMap.get(Numberz.EIGHT), Int64.make(0,8)) == 0,
+                        "crazy3.UserMap.get(Numberz.EIGHT) == 8");
+            rslt.Expect( Int64.compare( crazy2.userMap.get(Numberz.FIVE), Int64.make(0,5)) == 0,
+                        "crazy2.UserMap.get(Numberz.FIVE) == 5");
+            rslt.Expect( Int64.compare( crazy3.userMap.get(Numberz.FIVE), Int64.make(0,5)) == 0,
+                        "crazy3.UserMap.get(Numberz.FIVE) == 5");
 
-			var crz2iter = crazy2.xtructs.iterator();
-			var crz3iter = crazy3.xtructs.iterator();
-			rslt.Expect( crz2iter.hasNext() && crz3iter.hasNext(), "crz2iter.hasNext() && crz3iter.hasNext()");
-			var goodbye2 = crz2iter.next();
-			var goodbye3 = crz3iter.next();
-			rslt.Expect( crz2iter.hasNext() && crz3iter.hasNext(), "crz2iter.hasNext() && crz3iter.hasNext()");
-			var hello2 = crz2iter.next();
-			var hello3 = crz3iter.next();
-			rslt.Expect( ! (crz2iter.hasNext() || crz3iter.hasNext()), "! (crz2iter.hasNext() || crz3iter.hasNext())");
+            var crz2iter = crazy2.xtructs.iterator();
+            var crz3iter = crazy3.xtructs.iterator();
+            rslt.Expect( crz2iter.hasNext() && crz3iter.hasNext(), "crz2iter.hasNext() && crz3iter.hasNext()");
+            var goodbye2 = crz2iter.next();
+            var goodbye3 = crz3iter.next();
+            rslt.Expect( crz2iter.hasNext() && crz3iter.hasNext(), "crz2iter.hasNext() && crz3iter.hasNext()");
+            var hello2 = crz2iter.next();
+            var hello3 = crz3iter.next();
+            rslt.Expect( ! (crz2iter.hasNext() || crz3iter.hasNext()), "! (crz2iter.hasNext() || crz3iter.hasNext())");
 
-			rslt.Expect( hello2.string_thing == "Hello2", 'hello2.String_thing == "Hello2"');
-			rslt.Expect( hello2.byte_thing == 2, 'hello2.Byte_thing == 2');
-			rslt.Expect( hello2.i32_thing == 2, 'hello2.I32_thing == 2');
-			rslt.Expect( Int64.compare( hello2.i64_thing, Int64.make(0,2)) == 0, 'hello2.I64_thing == 2');
-			rslt.Expect( hello3.string_thing == "Hello2", 'hello3.String_thing == "Hello2"');
-			rslt.Expect( hello3.byte_thing == 2, 'hello3.Byte_thing == 2');
-			rslt.Expect( hello3.i32_thing == 2, 'hello3.I32_thing == 2');
-			rslt.Expect( Int64.compare( hello3.i64_thing, Int64.make(0,2)) == 0, 'hello3.I64_thing == 2');
+            rslt.Expect( hello2.string_thing == "Hello2", 'hello2.String_thing == "Hello2"');
+            rslt.Expect( hello2.byte_thing == 2, 'hello2.Byte_thing == 2');
+            rslt.Expect( hello2.i32_thing == 2, 'hello2.I32_thing == 2');
+            rslt.Expect( Int64.compare( hello2.i64_thing, Int64.make(0,2)) == 0, 'hello2.I64_thing == 2');
+            rslt.Expect( hello3.string_thing == "Hello2", 'hello3.String_thing == "Hello2"');
+            rslt.Expect( hello3.byte_thing == 2, 'hello3.Byte_thing == 2');
+            rslt.Expect( hello3.i32_thing == 2, 'hello3.I32_thing == 2');
+            rslt.Expect( Int64.compare( hello3.i64_thing, Int64.make(0,2)) == 0, 'hello3.I64_thing == 2');
 
-			rslt.Expect( goodbye2.string_thing == "Goodbye4", 'goodbye2.String_thing == "Goodbye4"');
-			rslt.Expect( goodbye2.byte_thing == 4, 'goodbye2.Byte_thing == 4');
-			rslt.Expect( goodbye2.i32_thing == 4, 'goodbye2.I32_thing == 4');
-			rslt.Expect( Int64.compare( goodbye2.i64_thing, Int64.make(0,4)) == 0, 'goodbye2.I64_thing == 4');
-			rslt.Expect( goodbye3.string_thing == "Goodbye4", 'goodbye3.String_thing == "Goodbye4"');
-			rslt.Expect( goodbye3.byte_thing == 4, 'goodbye3.Byte_thing == 4');
-			rslt.Expect( goodbye3.i32_thing == 4, 'goodbye3.I32_thing == 4');
-			rslt.Expect( Int64.compare( goodbye3.i64_thing, Int64.make(0,4)) == 0, 'goodbye3.I64_thing == 4');
-		}
+            rslt.Expect( goodbye2.string_thing == "Goodbye4", 'goodbye2.String_thing == "Goodbye4"');
+            rslt.Expect( goodbye2.byte_thing == 4, 'goodbye2.Byte_thing == 4');
+            rslt.Expect( goodbye2.i32_thing == 4, 'goodbye2.I32_thing == 4');
+            rslt.Expect( Int64.compare( goodbye2.i64_thing, Int64.make(0,4)) == 0, 'goodbye2.I64_thing == 4');
+            rslt.Expect( goodbye3.string_thing == "Goodbye4", 'goodbye3.String_thing == "Goodbye4"');
+            rslt.Expect( goodbye3.byte_thing == 4, 'goodbye3.Byte_thing == 4');
+            rslt.Expect( goodbye3.i32_thing == 4, 'goodbye3.I32_thing == 4');
+            rslt.Expect( Int64.compare( goodbye3.i64_thing, Int64.make(0,4)) == 0, 'goodbye3.I64_thing == 4');
+        }
 
-		var arg0 = 1;
-		var arg1 = 2;
-		var arg2 = Int64.make( 0x7FFFFFFF,0xFFFFFFFF);
-		var multiDict = new IntMap< String>();
-		multiDict.set(1, "one");
-		var arg4 = Numberz.FIVE;
-		var arg5 = Int64.make(0,5000000);
-		trace("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + "," + multiDict + "," + arg4 + "," + arg5 + ")");
-		var multiResponse = client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5);
-		trace(" = Xtruct(byte_thing:" + multiResponse.byte_thing + ",string_thing:" + multiResponse.string_thing
-					+ ",i32_thing:" + multiResponse.i32_thing 
-			        + ",i64_thing:" + Int64.toStr(multiResponse.i64_thing) + ")");
+        var arg0 = 1;
+        var arg1 = 2;
+        var arg2 = Int64.make( 0x7FFFFFFF,0xFFFFFFFF);
+        var multiDict = new IntMap< String>();
+        multiDict.set(1, "one");
+        var arg4 = Numberz.FIVE;
+        var arg5 = Int64.make(0,5000000);
+        trace("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + "," + multiDict + "," + arg4 + "," + arg5 + ")");
+        var multiResponse = client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5);
+        trace(" = Xtruct(byte_thing:" + multiResponse.byte_thing + ",string_thing:" + multiResponse.string_thing
+                    + ",i32_thing:" + multiResponse.i32_thing
+                    + ",i64_thing:" + Int64.toStr(multiResponse.i64_thing) + ")");
 
-		rslt.Expect( multiResponse.string_thing == "Hello2", 'multiResponse.String_thing == "Hello2"');
-		rslt.Expect( multiResponse.byte_thing == arg0, 'multiResponse.Byte_thing == arg0');
-		rslt.Expect( multiResponse.i32_thing == arg1, 'multiResponse.I32_thing == arg1');
-		rslt.Expect( Int64.compare( multiResponse.i64_thing, arg2) == 0, 'multiResponse.I64_thing == arg2');
+        rslt.Expect( multiResponse.string_thing == "Hello2", 'multiResponse.String_thing == "Hello2"');
+        rslt.Expect( multiResponse.byte_thing == arg0, 'multiResponse.Byte_thing == arg0');
+        rslt.Expect( multiResponse.i32_thing == arg1, 'multiResponse.I32_thing == arg1');
+        rslt.Expect( Int64.compare( multiResponse.i64_thing, arg2) == 0, 'multiResponse.I64_thing == arg2');
 
 
-		rslt.StartTestGroup( 0);
+        rslt.StartTestGroup( 0);
 
-		trace("Test Oneway(1)");
-		client.testOneway(1);
+        trace("Test Oneway(1)");
+        client.testOneway(1);
 
-		if( ! args.skipSpeedTest) {
-			trace("Test Calltime()");
-			var difft = Timer.stamp();
-			for ( k in 0 ... 1000) {
-				client.testVoid();
-			}
-			difft = Timer.stamp() - difft;
-			trace('$difft ms per testVoid() call');
-		}
-	}
+        if( ! args.skipSpeedTest) {
+            trace("Test Calltime()");
+            var difft = Timer.stamp();
+            for ( k in 0 ... 1000) {
+                client.testVoid();
+            }
+            difft = Timer.stamp() - difft;
+            trace('$difft ms per testVoid() call');
+        }
+    }
 }
