Removed duplicated code, made adding tests easier