removed test function and added removal of tmpfile