I think this fixes 2 bugs

See commits. make test wouldn't produce anything useful without these two changes.