add semi-functional tests

- don't mock Tempfile, and check its file mode