Improved temp file usage in tests

Instead of using "/tmp/whatever", use tmpfile() which works on all
operating systems.