Tests & refactoring