add multi-thread test, fix compiling on OS X