test: fix compilation under win32 (rearrange thread_setup() code) (cherry picked from commit 34d51e1bc9c650c4d012fe3024f7777c819ba969)