some test cases and bug fixes