Add tests to confirm that only up-to-date nodes can become primary. Improve testing harness.