Added tests, greened, refactored