Add a test to check if a Run's delayed_job has failed.

If the job is present then its failed_at field is checked. This in turn now
allows us to delete a run if its job has failed but its state is still running.