refactor file handlers out of main spec helper