diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
old mode 100755
new mode 100644
index a343221..6d2a260
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -50,7 +50,7 @@
 
 #include <signal.h>
 #if _WIN32
-   #include <thrift/windows/TWinsockSingleton.h>
+#include <thrift/windows/TWinsockSingleton.h>
 #endif
 
 using namespace std;
@@ -68,14 +68,12 @@
 #define EXECUTABLE_FILE_NAME_LENGTH 19
 
 class TestHandler : public ThriftTestIf {
- public:
+public:
   TestHandler() {}
 
-  void testVoid() {
-    printf("testVoid()\n");
-  }
+  void testVoid() { printf("testVoid()\n"); }
 
-  void testString(string& out, const string &thing) {
+  void testString(string& out, const string& thing) {
     printf("testString(\"%s\")\n", thing.c_str());
     out = thing;
   }
@@ -100,18 +98,28 @@
     return thing;
   }
 
-  void testStruct(Xtruct& out, const Xtruct &thing) {
-    printf("testStruct({\"%s\", %d, %d, %" PRId64 "})\n", thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing);
+  void testStruct(Xtruct& out, const Xtruct& thing) {
+    printf("testStruct({\"%s\", %d, %d, %" PRId64 "})\n",
+           thing.string_thing.c_str(),
+           (int)thing.byte_thing,
+           thing.i32_thing,
+           thing.i64_thing);
     out = thing;
   }
 
   void testNest(Xtruct2& out, const Xtruct2& nest) {
-    const Xtruct &thing = nest.struct_thing;
-    printf("testNest({%d, {\"%s\", %d, %d, %" PRId64 "}, %d})\n", (int)nest.byte_thing, thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing, nest.i32_thing);
+    const Xtruct& thing = nest.struct_thing;
+    printf("testNest({%d, {\"%s\", %d, %d, %" PRId64 "}, %d})\n",
+           (int)nest.byte_thing,
+           thing.string_thing.c_str(),
+           (int)thing.byte_thing,
+           thing.i32_thing,
+           thing.i64_thing,
+           nest.i32_thing);
     out = nest;
   }
 
-  void testMap(map<int32_t, int32_t> &out, const map<int32_t, int32_t> &thing) {
+  void testMap(map<int32_t, int32_t>& out, const map<int32_t, int32_t>& thing) {
     printf("testMap({");
     map<int32_t, int32_t>::const_iterator m_iter;
     bool first = true;
@@ -127,7 +135,8 @@
     out = thing;
   }
 
-  void testStringMap(map<std::string, std::string> &out, const map<std::string, std::string> &thing) {
+  void testStringMap(map<std::string, std::string>& out,
+                     const map<std::string, std::string>& thing) {
     printf("testMap({");
     map<std::string, std::string>::const_iterator m_iter;
     bool first = true;
@@ -143,7 +152,7 @@
     out = thing;
   }
 
-  void testSet(set<int32_t> &out, const set<int32_t> &thing) {
+  void testSet(set<int32_t>& out, const set<int32_t>& thing) {
     printf("testSet({");
     set<int32_t>::const_iterator s_iter;
     bool first = true;
@@ -159,7 +168,7 @@
     out = thing;
   }
 
-  void testList(vector<int32_t> &out, const vector<int32_t> &thing) {
+  void testList(vector<int32_t>& out, const vector<int32_t>& thing) {
     printf("testList({");
     vector<int32_t>::const_iterator l_iter;
     bool first = true;
@@ -185,23 +194,22 @@
     return thing;
   }
 
-  void testMapMap(map<int32_t, map<int32_t,int32_t> > &mapmap, const int32_t hello) {
+  void testMapMap(map<int32_t, map<int32_t, int32_t> >& mapmap, const int32_t hello) {
     printf("testMapMap(%d)\n", hello);
 
-    map<int32_t,int32_t> pos;
-    map<int32_t,int32_t> neg;
+    map<int32_t, int32_t> pos;
+    map<int32_t, int32_t> neg;
     for (int i = 1; i < 5; i++) {
-      pos.insert(make_pair(i,i));
-      neg.insert(make_pair(-i,-i));
+      pos.insert(make_pair(i, i));
+      neg.insert(make_pair(-i, -i));
     }
 
     mapmap.insert(make_pair(4, pos));
     mapmap.insert(make_pair(-4, neg));
-
   }
 
-  void testInsanity(map<UserId, map<Numberz::type,Insanity> > &insane, const Insanity &argument) {
-    (void) argument;
+  void testInsanity(map<UserId, map<Numberz::type, Insanity> >& insane, const Insanity& argument) {
+    (void)argument;
     printf("testInsanity()\n");
 
     Xtruct hello;
@@ -237,13 +245,11 @@
 
     printf("return");
     printf(" = {");
-    map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter;
+    map<UserId, map<Numberz::type, Insanity> >::const_iterator i_iter;
     for (i_iter = insane.begin(); i_iter != insane.end(); ++i_iter) {
       printf("%" PRId64 " => {", i_iter->first);
-      map<Numberz::type,Insanity>::const_iterator i2_iter;
-      for (i2_iter = i_iter->second.begin();
-           i2_iter != i_iter->second.end();
-           ++i2_iter) {
+      map<Numberz::type, Insanity>::const_iterator i2_iter;
+      for (i2_iter = i_iter->second.begin(); i2_iter != i_iter->second.end(); ++i2_iter) {
         printf("%d => {", i2_iter->first);
         map<Numberz::type, UserId> userMap = i2_iter->second.userMap;
         map<Numberz::type, UserId>::const_iterator um;
@@ -257,7 +263,11 @@
         vector<Xtruct>::const_iterator x;
         printf("{");
         for (x = xtructs.begin(); x != xtructs.end(); ++x) {
-          printf("{\"%s\", %d, %d, %" PRId64 "}, ", x->string_thing.c_str(), (int)x->byte_thing, x->i32_thing, x->i64_thing);
+          printf("{\"%s\", %d, %d, %" PRId64 "}, ",
+                 x->string_thing.c_str(),
+                 (int)x->byte_thing,
+                 x->i32_thing,
+                 x->i64_thing);
         }
         printf("}");
 
@@ -266,14 +276,18 @@
       printf("}, ");
     }
     printf("}\n");
-
-
   }
 
-  void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string>  &arg3, const Numberz::type arg4, const UserId arg5) {
-    (void) arg3;
-    (void) arg4;
-    (void) arg5;
+  void testMulti(Xtruct& hello,
+                 const int8_t arg0,
+                 const int32_t arg1,
+                 const int64_t arg2,
+                 const std::map<int16_t, std::string>& arg3,
+                 const Numberz::type arg4,
+                 const UserId arg5) {
+    (void)arg3;
+    (void)arg4;
+    (void)arg5;
 
     printf("testMulti()\n");
 
@@ -283,9 +297,7 @@
     hello.i64_thing = (int64_t)arg2;
   }
 
-  void testException(const std::string &arg)
-    throw(Xception, apache::thrift::TException)
-  {
+  void testException(const std::string& arg) throw(Xception, apache::thrift::TException) {
     printf("testException(%s)\n", arg.c_str());
     if (arg.compare("Xception") == 0) {
       Xception e;
@@ -302,7 +314,9 @@
     }
   }
 
-  void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) throw(Xception, Xception2) {
+  void testMultiException(Xtruct& result,
+                          const std::string& arg0,
+                          const std::string& arg1) throw(Xception, Xception2) {
 
     printf("testMultiException(%s, %s)\n", arg0.c_str(), arg1.c_str());
 
@@ -329,28 +343,23 @@
   }
 };
 
-
 class TestProcessorEventHandler : public TProcessorEventHandler {
   virtual void* getContext(const char* fn_name, void* serverContext) {
-    (void) serverContext;
+    (void)serverContext;
     return new std::string(fn_name);
   }
   virtual void freeContext(void* ctx, const char* fn_name) {
-    (void) fn_name;
+    (void)fn_name;
     delete static_cast<std::string*>(ctx);
   }
-  virtual void preRead(void* ctx, const char* fn_name) {
-    communicate("preRead", ctx, fn_name);
-  }
+  virtual void preRead(void* ctx, const char* fn_name) { communicate("preRead", ctx, fn_name); }
   virtual void postRead(void* ctx, const char* fn_name, uint32_t bytes) {
-    (void) bytes;
+    (void)bytes;
     communicate("postRead", ctx, fn_name);
   }
-  virtual void preWrite(void* ctx, const char* fn_name) {
-    communicate("preWrite", ctx, fn_name);
-  }
+  virtual void preWrite(void* ctx, const char* fn_name) { communicate("preWrite", ctx, fn_name); }
   virtual void postWrite(void* ctx, const char* fn_name, uint32_t bytes) {
-    (void) bytes;
+    (void)bytes;
     communicate("postWrite", ctx, fn_name);
   }
   virtual void asyncComplete(void* ctx, const char* fn_name) {
@@ -365,7 +374,6 @@
   }
 };
 
-
 class TestHandlerAsync : public ThriftTestCobSvIf {
 public:
   TestHandlerAsync(boost::shared_ptr<TestHandler>& handler) : _delegate(handler) {}
@@ -376,7 +384,8 @@
     cob();
   }
 
-  virtual void testString(tcxx::function<void(std::string const& _return)> cob, const std::string& thing) {
+  virtual void testString(tcxx::function<void(std::string const& _return)> cob,
+                          const std::string& thing) {
     std::string res;
     _delegate->testString(res, thing);
     cob(res);
@@ -414,31 +423,37 @@
     cob(res);
   }
 
-  virtual void testMap(tcxx::function<void(std::map<int32_t, int32_t>  const& _return)> cob, const std::map<int32_t, int32_t> & thing) {
+  virtual void testMap(tcxx::function<void(std::map<int32_t, int32_t> const& _return)> cob,
+                       const std::map<int32_t, int32_t>& thing) {
     std::map<int32_t, int32_t> res;
     _delegate->testMap(res, thing);
     cob(res);
   }
 
-  virtual void testStringMap(tcxx::function<void(std::map<std::string, std::string>  const& _return)> cob, const std::map<std::string, std::string> & thing) {
+  virtual void testStringMap(
+      tcxx::function<void(std::map<std::string, std::string> const& _return)> cob,
+      const std::map<std::string, std::string>& thing) {
     std::map<std::string, std::string> res;
     _delegate->testStringMap(res, thing);
     cob(res);
   }
 
-  virtual void testSet(tcxx::function<void(std::set<int32_t>  const& _return)> cob, const std::set<int32_t> & thing) {
+  virtual void testSet(tcxx::function<void(std::set<int32_t> const& _return)> cob,
+                       const std::set<int32_t>& thing) {
     std::set<int32_t> res;
     _delegate->testSet(res, thing);
     cob(res);
   }
 
-  virtual void testList(tcxx::function<void(std::vector<int32_t>  const& _return)> cob, const std::vector<int32_t> & thing) {
+  virtual void testList(tcxx::function<void(std::vector<int32_t> const& _return)> cob,
+                        const std::vector<int32_t>& thing) {
     std::vector<int32_t> res;
     _delegate->testList(res, thing);
     cob(res);
   }
 
-  virtual void testEnum(tcxx::function<void(Numberz::type const& _return)> cob, const Numberz::type thing) {
+  virtual void testEnum(tcxx::function<void(Numberz::type const& _return)> cob,
+                        const Numberz::type thing) {
     Numberz::type res = _delegate->testEnum(thing);
     cob(res);
   }
@@ -448,39 +463,56 @@
     cob(res);
   }
 
-  virtual void testMapMap(tcxx::function<void(std::map<int32_t, std::map<int32_t, int32_t> >  const& _return)> cob, const int32_t hello) {
+  virtual void testMapMap(
+      tcxx::function<void(std::map<int32_t, std::map<int32_t, int32_t> > const& _return)> cob,
+      const int32_t hello) {
     std::map<int32_t, std::map<int32_t, int32_t> > res;
     _delegate->testMapMap(res, hello);
     cob(res);
   }
 
-  virtual void testInsanity(tcxx::function<void(std::map<UserId, std::map<Numberz::type, Insanity> >  const& _return)> cob, const Insanity& argument) {
+  virtual void testInsanity(
+      tcxx::function<void(std::map<UserId, std::map<Numberz::type, Insanity> > const& _return)> cob,
+      const Insanity& argument) {
     std::map<UserId, std::map<Numberz::type, Insanity> > res;
     _delegate->testInsanity(res, argument);
     cob(res);
- }
+  }
 
-  virtual void testMulti(tcxx::function<void(Xtruct const& _return)> cob, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string> & arg3, const Numberz::type arg4, const UserId arg5) {
+  virtual void testMulti(tcxx::function<void(Xtruct const& _return)> cob,
+                         const int8_t arg0,
+                         const int32_t arg1,
+                         const int64_t arg2,
+                         const std::map<int16_t, std::string>& arg3,
+                         const Numberz::type arg4,
+                         const UserId arg5) {
     Xtruct res;
     _delegate->testMulti(res, arg0, arg1, arg2, arg3, arg4, arg5);
     cob(res);
   }
 
-  virtual void testException(tcxx::function<void()> cob, tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, const std::string& arg) {
+  virtual void testException(
+      tcxx::function<void()> cob,
+      tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
+      const std::string& arg) {
     try {
       _delegate->testException(arg);
-    } catch(const apache::thrift::TException& e) {
+    } catch (const apache::thrift::TException& e) {
       exn_cob(apache::thrift::TDelayedException::delayException(e));
       return;
     }
     cob();
   }
 
-  virtual void testMultiException(tcxx::function<void(Xtruct const& _return)> cob, tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob, const std::string& arg0, const std::string& arg1) {
+  virtual void testMultiException(
+      tcxx::function<void(Xtruct const& _return)> cob,
+      tcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
+      const std::string& arg0,
+      const std::string& arg1) {
     Xtruct res;
     try {
       _delegate->testMultiException(res, arg0, arg1);
-    } catch(const apache::thrift::TException& e) {
+    } catch (const apache::thrift::TException& e) {
       exn_cob(apache::thrift::TDelayedException::delayException(e));
       return;
     }
@@ -496,13 +528,12 @@
   boost::shared_ptr<TestHandler> _delegate;
 };
 
-
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
 
   string file_path = boost::filesystem::system_complete(argv[0]).string();
-  string dir_path = file_path.substr(0, file_path.size()-EXECUTABLE_FILE_NAME_LENGTH);
+  string dir_path = file_path.substr(0, file_path.size() - EXECUTABLE_FILE_NAME_LENGTH);
 
-  #if _WIN32
+#if _WIN32
   transport::TWinsockSingleton::create();
 #endif
   int port = 9090;
@@ -513,32 +544,35 @@
   string domain_socket = "";
   size_t workers = 4;
 
-
   boost::program_options::options_description desc("Allowed options");
-  desc.add_options()
-      ("help,h", "produce help message")
-      ("port", boost::program_options::value<int>(&port)->default_value(port), "Port number to listen")
-	  ("domain-socket", boost::program_options::value<string>(&domain_socket)->default_value(domain_socket),
-	    "Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)")
-      ("server-type", boost::program_options::value<string>(&server_type)->default_value(server_type),
-        "type of server, \"simple\", \"thread-pool\", \"threaded\", or \"nonblocking\"")
-      ("transport", boost::program_options::value<string>(&transport_type)->default_value(transport_type),
-        "transport: buffered, framed, http")
-      ("protocol", boost::program_options::value<string>(&protocol_type)->default_value(protocol_type),
-        "protocol: binary, compact, json")
-	  ("ssl", "Encrypted Transport using SSL")
-	  ("processor-events", "processor-events")
-      ("workers,n", boost::program_options::value<size_t>(&workers)->default_value(workers),
-        "Number of thread pools workers. Only valid for thread-pool server type")
-  ;
+  desc.add_options()("help,h", "produce help message")(
+      "port",
+      boost::program_options::value<int>(&port)->default_value(port),
+      "Port number to listen")("domain-socket",
+                               boost::program_options::value<string>(&domain_socket)
+                                   ->default_value(domain_socket),
+                               "Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)")(
+      "server-type",
+      boost::program_options::value<string>(&server_type)->default_value(server_type),
+      "type of server, \"simple\", \"thread-pool\", \"threaded\", or \"nonblocking\"")(
+      "transport",
+      boost::program_options::value<string>(&transport_type)->default_value(transport_type),
+      "transport: buffered, framed, http")(
+      "protocol",
+      boost::program_options::value<string>(&protocol_type)->default_value(protocol_type),
+      "protocol: binary, compact, json")("ssl", "Encrypted Transport using SSL")(
+      "processor-events",
+      "processor-events")("workers,n",
+                          boost::program_options::value<size_t>(&workers)->default_value(workers),
+                          "Number of thread pools workers. Only valid for thread-pool server type");
 
   boost::program_options::variables_map vm;
   boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
   boost::program_options::notify(vm);
 
   if (vm.count("help")) {
-      cout << desc << "\n";
-      return 1;
+    cout << desc << "\n";
+    return 1;
   }
 
   try {
@@ -548,7 +582,7 @@
       } else if (server_type == "threaded") {
       } else if (server_type == "nonblocking") {
       } else {
-          throw invalid_argument("Unknown server type "+server_type);
+        throw invalid_argument("Unknown server type " + server_type);
       }
     }
 
@@ -557,7 +591,7 @@
       } else if (protocol_type == "compact") {
       } else if (protocol_type == "json") {
       } else {
-          throw invalid_argument("Unknown protocol type "+protocol_type);
+        throw invalid_argument("Unknown protocol type " + protocol_type);
       }
     }
 
@@ -566,7 +600,7 @@
       } else if (transport_type == "framed") {
       } else if (transport_type == "http") {
       } else {
-          throw invalid_argument("Unknown transport type "+transport_type);
+        throw invalid_argument("Unknown transport type " + transport_type);
       }
     }
 
@@ -589,7 +623,8 @@
     boost::shared_ptr<TProtocolFactory> compactProtocolFactory(new TCompactProtocolFactory());
     protocolFactory = compactProtocolFactory;
   } else {
-    boost::shared_ptr<TProtocolFactory> binaryProtocolFactory(new TBinaryProtocolFactoryT<TBufferBase>());
+    boost::shared_ptr<TProtocolFactory> binaryProtocolFactory(
+        new TBinaryProtocolFactoryT<TBufferBase>());
     protocolFactory = binaryProtocolFactory;
   }
 
@@ -598,8 +633,8 @@
   boost::shared_ptr<ThriftTestProcessor> testProcessor(new ThriftTestProcessor(testHandler));
 
   if (vm.count("processor-events")) {
-    testProcessor->setEventHandler(boost::shared_ptr<TProcessorEventHandler>(
-          new TestProcessorEventHandler()));
+    testProcessor->setEventHandler(
+        boost::shared_ptr<TProcessorEventHandler>(new TestProcessorEventHandler()));
   }
 
   // Transport
@@ -637,8 +672,8 @@
   }
 
   // Server Info
-  cout << "Starting \"" << server_type << "\" server ("
-    << transport_type << "/" << protocol_type << ") listen on: " << domain_socket;
+  cout << "Starting \"" << server_type << "\" server (" << transport_type << "/" << protocol_type
+       << ") listen on: " << domain_socket;
   if (port != 0) {
     cout << port;
   }
@@ -648,17 +683,13 @@
   boost::shared_ptr<apache::thrift::server::TServer> server;
 
   if (server_type == "simple") {
-    server.reset(new TSimpleServer(testProcessor,
-                               serverSocket,
-                               transportFactory,
-                               protocolFactory));
+    server.reset(new TSimpleServer(testProcessor, serverSocket, transportFactory, protocolFactory));
   } else if (server_type == "thread-pool") {
 
-    boost::shared_ptr<ThreadManager> threadManager =
-      ThreadManager::newSimpleThreadManager(workers);
+    boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers);
 
-    boost::shared_ptr<PlatformThreadFactory> threadFactory =
-      boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+    boost::shared_ptr<PlatformThreadFactory> threadFactory
+        = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
     threadManager->threadFactory(threadFactory);
 
@@ -671,15 +702,15 @@
                                        threadManager));
   } else if (server_type == "threaded") {
 
-    server.reset(new TThreadedServer(testProcessor,
-                                   serverSocket,
-                                   transportFactory,
-                                   protocolFactory));
+    server.reset(
+        new TThreadedServer(testProcessor, serverSocket, transportFactory, protocolFactory));
   } else if (server_type == "nonblocking") {
-    if(transport_type == "http") {
+    if (transport_type == "http") {
       boost::shared_ptr<TestHandlerAsync> testHandlerAsync(new TestHandlerAsync(testHandler));
-      boost::shared_ptr<TAsyncProcessor> testProcessorAsync(new ThriftTestAsyncProcessor(testHandlerAsync));
-      boost::shared_ptr<TAsyncBufferProcessor> testBufferProcessor(new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory));
+      boost::shared_ptr<TAsyncProcessor> testProcessorAsync(
+          new ThriftTestAsyncProcessor(testHandlerAsync));
+      boost::shared_ptr<TAsyncBufferProcessor> testBufferProcessor(
+          new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory));
 
       // not loading nonblockingServer into "server" because
       // TEvhttpServer doesn't inherit from TServer, and doesn't
@@ -691,17 +722,18 @@
     }
   }
 
-  if(server.get() != NULL)
-  {
+  if (server.get() != NULL) {
     apache::thrift::concurrency::PlatformThreadFactory factory;
     factory.setDetached(false);
     boost::shared_ptr<apache::thrift::concurrency::Runnable> serverThreadRunner(server);
-    boost::shared_ptr<apache::thrift::concurrency::Thread> thread = factory.newThread(serverThreadRunner);
+    boost::shared_ptr<apache::thrift::concurrency::Thread> thread
+        = factory.newThread(serverThreadRunner);
     thread->start();
 
     // HACK: cross language test suite is unable to handle cin properly
     //       that's why we stay in a endless loop here
-    while(1){}
+    while (1) {
+    }
     // FIXME: find another way to stop the server (e.g. a signal)
     // cout<<"Press enter to stop the server."<<endl;
     // cin.ignore(); //wait until a key is pressed
