Fix committed algorithm

Fix the algorithm to reflect that from the paper:

On a successfl AppendEntriesResponse, sort matchIndex and pick the middle value as the committed index.
Factor out stepDown logic
Add ReplicaManager tests
Add BaseState tests
Add DefaultContext tests