Refactor MozAPIKey code

And fix some nits from earlier PRs.