test: make unit tests work on Windows

Due to the lack of getopt() on Windows it still will not accept
command line options (for running only a specific test, or setting
the seed), but at least they run.
Support thread-specific storage destructors on Windows
Fix mtx_trylock on Windows when lock already acquired with mtx_trylock