rework and also support mocking stderr