Squashed bugs, added tests and another test case