raft: fix log append and add extensive test for it