Fix bug in test; found by AddressSanitizer