Possible error with kirbytext using textarea

I have a need to indent text from a textarea field and have what looks like a bug with kirbytext. The output is generating incomplete p tags. I have reproduced this in the starterkit using the code below. If I replace kirbytext with kirbytextRaw and make the last line of the textarea field italic, I get incomplete em tags. Any suggestions would be appreciated.

  <?php if($page->test2()->isNotEmpty()):?>
    <strong>TEST:</strong>
    <?php $test = str::split($page->test2()->kirbytext(),'<br />');?>
    <?php if(size($test) > 1): ?>
      <br />
      <?php foreach($test as $tt):?>
        <span style="margin-left: 1em;"><?=$tt?></span> <br />
      <?php endforeach ?>
    <?php else: ?>
      <?= $page->test2()->kirbytext() ?><br />
    <?php endif ?>
  <?php endif ?>

That’s not so surprising. I don’t know your original text, but I think you are trying to split some text which leaves you with an opening p tag on the first element, and a closing one in the last element of the resulting array. I think you’d be better of with removing the p tags and all other stuff that doesn’t belong there and get your items using regex. Which might get a bit difficult if you use italics or bold.

Thanks for the reply.
The text I used for testing is
test1
test2
test3

If I remove the p tags using kirrbytextRaw in place of kirbytext in the above code I don’t have any problems with output since no p tag is generated. But if I make the last line of text in the textarea italic (bold will probably produce the same result) text3, then I get an incomplete em tag in the output.

Is this and issue with kirbytext?