refactor API tests