Test for UniqueUriSegmentGenerationService, related refactorings and bug fixes.