2.0.1 fix retries operations

The pull request #324 does not deal with write operations after a replicaset reconfiguration.
And the tests with replicaset simulator does not represent the real world where the election of a new primary can take some seconds.

I moved some of the code I did on pull request #315 to this one based on tag 2.0.1.
I hope you can check and merge it on master.
The tests are done with a real replicaset using the stepDown command.

Regards,
Wandenberg