API tests and fixes.