added few test cases and refactored few