Refactored AnkiServer/apps/rest_app.py so that it is actually testable.