refactoring and added new test classes