Fixed test case, and prevent segmentation faults.

Found while looking at Travis.