tighten up file handling on test