fix add lock
fix test for data race
refactor use separate lock instead of having setTerm function
Merge pull request #123 from goraft/fix-data-race

Fix data race