Fix tests for authentication

- Add some doctests around getting auth tokens from the environment and
  make it a bit more robust.
- Add managing of AUTH_TOKENS environment variable to the test helper so
  that it's explicit that the auth token is being set.
- Factor out the two test helper functions into their own module as
  they were starting to dominate the test module.