Still to be reviewed/fixed: tests/test-*, tests/[cfrs]*
Fixed a number of tests that didn't handle the programCount == 1 case correctly.