Changed CounterModule to generic template InstanceFactory<T>