Refactoring, add tests for files