Moved test script TMPDIR code into its own package