bug fix for checking if file, and bug fix for test