Tom/Eduardo - adding code to cope with being unable to create users when nodes are not master (i.e. when replicaset is not yet configured or node is a secondary). Moving some more functions to helper.