Schedule retry checks

I have added checks for the schedule and retry sets so the Scaler won't downscale to 0 and leaves the process running until Retries or Scheduled jobs have a chance to start.

Includes tests and new way to make a unique database connection for tests.