Fix scheduling when no tasks are running.
 Add more tests to cover this case.