tests added and refactored