polish test cases and code