test(collapse): clone scope references to prevent test scope leakage (fixes #1058)