fix a scheduler edge case and introduce tests