Adding some test cases, refactoring main