improve injectFieldByType to work correctly with injecting mocks