Use before hook in collection spec to deal with gc issues