refactor file_writer and specs