further work and tests on reference count