Fix race condition that would occasionally cause one node that was syncing to multiple
other nodes from ever falling into sync with the loser of the race.
Add option to write created key to a JSON file for use in bts_xt_client.