Refactoring unique job ID generation

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