add test cases and fix some little issues