more safty

Get the term before we check the state. 
We are not able to stop the heartbeat right after the state changes for now. 

This ensure the safety. 
With this change, I run raft-bench for tens millions of logs without a problem. 

I am aware of this might be kind of heck, and am going to refactor the whole process when I have time.