Fix refcount unit test.

Turns out that it is allowed to destroy a refcount without attaching
to it first.
(cherry picked from commit 0256b39bee909af0699beb429e7362d7f6942281)