Refactor main.py and tests for it

- read configuration from environment only in main() to make test
  more independent;
- get rid of tests scripts, use mox instead.

Change-Id: Ia34942a60b01b050ce66554026f6408d35f2e71f