(PE-3673) Move tempfile fns to core
(PE-3673) Add tests for temp-file and temp-dir