test: move mkdir & mkdtemp calls to common place and fix them on MSVC