Fix tmpdir logic and test outfile