fix tempfile leak
make tests pass