XWIKI-9563: Extension install freezes under some circumstances
* Reuse the job status only if it corresponds to the current extension/dependency
* Make sure the Velocity macros that 'return' values don't have side effects (if there is an existing variable with the name of the 'return' variable then it is set to null).
(cherry picked from commit dc1678cb4f1df967410c1e7cc9784e06eba8e557)