[UTILITIES] Introduce a RefCounted interface and basic impl

We already have two places duplicating this rather hairy logic, this
commit intorduces a new RefCoutned interace and an abstract implementation
that can be used for delegation. It factors out all the reference counting
and adds single and multithreaded test for it.
that is a copy / paste error I will fix