Fix tests and build on windows