def instantiate_service(peripheral, properties, initial_value=None, fixed_size=True, max_length=None):
    """
    Instantiate the service with the characteristic under test.

    Args:
        peripheral (BleDevice): device where the gatt server resides.
        properties (List[str]): Properties of the characteristic.
        initial_value (str): HEX representation of the initial value of the characteristic.
        fixed_size (Bool): True if the size of the characteristic is fixed and False otherwise.
        max_length (int): Maximum number of bytes occupied by the characteristic value.

    Returns:
        int: handle of the characteristic under test
    """
    gatt_server = peripheral.gattServer

    gatt_server.declareService(0xFFFB)
    gatt_server.declareCharacteristic(0xDEAF)
    gatt_server.setCharacteristicProperties(*properties)
    if initial_value is not None:
        gatt_server.setCharacteristicValue(initial_value)
    if fixed_size is True:
        gatt_server.setCharacteristicVariableLength(False)
    else:
        gatt_server.setCharacteristicVariableLength(True)
    if max_length is not None:
        gatt_server.setCharacteristicMaxLength(max_length)
    declared_service = gatt_server.commitService().result

    if initial_value is not None:
        assert initial_value == declared_service["characteristics"][0]["value"]

    return declared_service["characteristics"][0]["value_handle"]