Fix test failures in tests/test_logging_compat.py

Was failing with "ImportError: cannot import name log"

because tox.ini now sets TWIGGY_UNDER_TEST

This works around that by adding setup_module and teardown_module
functions which _populate_globals and _del_globals respectively and
moving imports into test methods where they're used.