Improve tests for API routes