Fix tests in test_api.py.