Fix crash in jobs.queue API. Add test case.