Added test cases to detect bugs like #188