quite complex to mock the stupid crappy function