added test suite and refactored