tests: Fix bug in "weak references" test.