Fixed tests
Refactoring