test_cmdline: fix string formatting bug.
main.py: set up logging facility before first log usage.
test_cmdline: fix environment variable readout.