Improved unit test to repro multithread bug, and fixed the cause of it due to MSVC non-threadsafe static init