Improve the number of steps when generating an ID of a new relationship, and add more tests, bug #53904