fixed problem with test files being in folder, added better file handling