Some minor refactorings
Adding new test cases