Test replsets

This PR closes #111 and adds acceptance tests for replsets. There are a few other bugfixes mixed in as I found them.