More test case and fixes