Refactoring unique job ID generation

Refactorings for the code that generates a unique job ID.

Note: this series depends on a previous series that renames --unique-id to --force-job-id and validates it.