MDL-25763 tool_replace: Returning correct error code