Added tests and refactored existing test