Various fixes to test_api