Refactoring & extra tests