discover_master procedure fix

See issue #5 for explanation.
This patch includes specs and example/test_wait_for_failover_write.rb for reference.