Write API tests