Refactored out replicaset state into seperate class to write test for state machine