Move API 401 helper functions to helpers.coffee