fix bugs to pass the test