Fix the fresh set_state() bug found by unittest