Ruby has a method for detecting temp directory.

It uses `ENV['TMPDIR'], ENV['TMP'], ENV['TEMP'], @@systmpdir, '/tmp', '.'`, so I left `ENV['TEMPDIR']` as is and let stdlib to handle the rest.
This is more convenient to write tests that don't specify tmpdir, since it may vary on different machines, while the pre-existing method wasn't detecting them that good.