avoid spurious log output during test
reduce code duplication in `test_main`