Implements factory cache setting and simpifies unit tests