fixed bugs to fix 2 test cases