Refactoring
Updated tests