Fix tempfolder on Windows. Extract test common code.