refactoring & first tests