Refactored duplicated code into JobRunner.php

* Also added an async flag to SpecialRunJobs so that it can be
  set to false to get a JSON blob back with a regular 200 status.

Change-Id: I2f5763e017684c3c61f3d3f27ddf7f7834bdfce2
(cherry picked from commit 094d901b88ff59501b7b3f38fb7f7241379acfdf)