Even more refactoring, tests updated and green