Refactor api's code
Modify api's test-cases