bug fixes, update test cases