refactor, try to fix several test cases