raft: refactor log append; fix related tests