Set debug by test_environment option. Fix #504