Added new test and refactored