Cleanups regarding temporary files in tests

Delete index files for temp files at the end of testing, and
do not write temp files within source directory.