Add unit test to trigger #1275 and an assert to prevent the segfault.