Preserve reference semantics correctly in test