Added some more test cases
More refactoring