Fix linking of tests in static Windows build.

Also fixes the "multiple definition" Emscripten issue, which was worked
around in f44af271df7b3a593649dc13036e593d57f9213c.