refactoring of code, changed test cases.