Some more refactoring.
Corrected a typo in test_endpoint, passing.