added second testcase and refactoring