win32 fixes

This fixes tests in general (their behavior was previously broken on all OSes) by actually using the tempfile filename; and it fixes the close/unlink behavior on windows, which cannot delete before closing.