fix some bug, add test case