raft: refactor isUpToDate and add a test