Refactored factory to not generate a new class for each new Mock to avoid memory leak