Use proper tempdir for temporary test files

Writing temporary files in source tree is just wrong and requires additional hacks on our side. Instead, use a directory inside system tempdir.