fix state transition bug, pass tests more reliably