Finished tests, started refactoring