Fixed build failure and test case on OSX