async def METHOD_NAME(
    mock_binary_messenger: AsyncMock, initial_state: EstopSummary
) -> None:
    """Test the factory function for the estop detector."""
    async def mock_send_and_receive(
        message: BinaryMessageDefinition, response_type: Type[BinaryMessageDefinition]
    ) -> BinaryMessageDefinition:
        if isinstance(message, EstopButtonPresentRequest):
            return EstopButtonDetectionChange(
                aux1_detected=UInt8Field(1 if initial_state.left_detected else 0),
                aux2_detected=UInt8Field(1 if initial_state.right_detected else 0),
            )
        if isinstance(message, EstopStateRequest):
            return EstopStateChange(
                engaged=UInt8Field(1 if initial_state.engaged else 0)
            )
        return response_type()
    mock_binary_messenger.send_and_receive.side_effect = mock_send_and_receive
    subject = await EstopDetector.build(usb_messenger=mock_binary_messenger)
    assert subject.status == initial_state
    mock_binary_messenger.add_listener.assert_called_once()
    async def mock_send_and_receive_error(
        message: BinaryMessageDefinition, response_type: Type[BinaryMessageDefinition]
    ) -> BinaryMessageDefinition:
        return AckFailed()
    mock_binary_messenger.send_and_receive.side_effect = mock_send_and_receive_error
    with pytest.raises(InternalUSBCommunicationError):
        subject = await EstopDetector.build(usb_messenger=mock_binary_messenger)