Make db limits test more robust

Also make wait_for_job in the global tests file more robust by
checking for a zero job ID