Fix tests on linux, osx, some on windows