refine TEST_MODE setting; add reset_session option