tests added
refactored code