MDL-42882 upgrade: Improvements to upgrade code

Suggested by Petr:
* Don't rely on single user for upgrade
* Make the pathnamehash generation a bit clearer (and add
  a test to verify its correctly formed).