Fix RuntimeError due to bad mocking