API test cleanup and refactoring