Fix order of mocks and module loading for tests