takeLock and processStalledJobs + tests

@remkoboschker ? wadda ya think