Thread and race condition safe tempfiles for testing