fix tests compilation on MSVC

There are some changes needed to compile under MSVC and MinGW.
Is it possible to use `_getpid` instead?

The only use of this function is to try to prevent two tests being run in parallel from trying to write to two databases with the same name... so it's not the end of the world if it doesn't work. But it might lead to some spurious test failures.