Refactor Token into a model, move helpers back to controller, add tests