more test cases and fixes