raft: fix log append; add tests