Test cleanup: do not leak FDs during test runs

Avoid leaking file descriptors during test runs. Instead use a secure
tempfile fixture that guarantees the file descriptor from
tempfile.mkstemp is closed and that performs the appropriate cleanup
on the tempfile name in the cleanup phase.

Change-Id: I7e1ddd3122d72d8850794df9467f7b6c0608ac2d
Merge "Test cleanup: do not leak FDs during test runs"