diff --git a/luamml-patches-amsmath.sty b/luamml-patches-amsmath.sty
index fa6ec7e..f8933c4 100644
--- a/luamml-patches-amsmath.sty
+++ b/luamml-patches-amsmath.sty
@@ -406,10 +406,3 @@
     }
   }
 }
-
-\cs_set:Npn \env@cases {
-  \let \@ifnextchar \new@ifnextchar
-  \left \lbrace
-    \def \arraystretch {1.2}
-    \array {@{}l@{\quad \luamml_flag_ignore:}l@{}}
-}
diff --git a/luamml-patches-kernel.sty b/luamml-patches-kernel.sty
index e03a991..457d14d 100644
--- a/luamml-patches-kernel.sty
+++ b/luamml-patches-kernel.sty
@@ -34,6 +34,13 @@
   \__luamml_kernel_phantom:Vnn \g__luamml_kernel_phantom_int
 }
 
+\cs_set:Npn \env@cases {
+  \let \@ifnextchar \new@ifnextchar
+  \left \lbrace
+    \def \arraystretch {1.2}
+    \array {@{}l@{\quad \luamml_flag_ignore:}l@{}}
+}
+
 \@ifpackageloaded {unicode-math} {} {
   \cs_new:Npn \__luamml_kernel_define_character:Nnn #1#2#3 {
     \cs_set:cpx { \cs_to_str:N #1 ~ } {
diff --git a/testfiles-lua/cases.mlr b/testfiles-lua/cases.mlr
new file mode 100644
index 0000000..78aa953
--- /dev/null
+++ b/testfiles-lua/cases.mlr
@@ -0,0 +1,161 @@
+<math xmlns:tex="http://typesetting.eu/2021/LuaMathML" xmlns="http://www.w3.org/1998/Math/MathML">
+  <mspace width="9.963pt" />
+  <mi intent="@ignore" />
+</math>
+<math xmlns:tex="http://typesetting.eu/2021/LuaMathML" xmlns="http://www.w3.org/1998/Math/MathML">
+  <mi tex:family="1">𝑎</mi>
+  <mo lspace="0.278em" rspace="0.278em" tex:class="rel">=</mo>
+  <mi tex:family="1">𝑏</mi>
+</math>
+<math xmlns:tex="http://typesetting.eu/2021/LuaMathML" xmlns="http://www.w3.org/1998/Math/MathML">
+  <mspace width="9.963pt" />
+  <mi intent="@ignore" />
+</math>
+<math display="block" xmlns:tex="http://typesetting.eu/2021/LuaMathML" xmlns="http://www.w3.org/1998/Math/MathML">
+  <mrow tex:class="inner">
+    <mo fence="true" lspace="0" rspace="0" symmetric="true">(</mo>
+    <mspace width="-4.981pt" />
+    <mpadded lspace="+4.981pt" width="+9.963pt">
+      <mtable>
+        <mtr>
+          <mtd>
+            <mn>1</mn>
+          </mtd>
+          <mtd>
+            <mn>0</mn>
+          </mtd>
+          <mtd>
+            <mn>0</mn>
+          </mtd>
+        </mtr>
+        <mtr>
+          <mtd>
+            <mn>0</mn>
+          </mtd>
+          <mtd>
+            <mn>1</mn>
+          </mtd>
+          <mtd>
+            <mn>0</mn>
+          </mtd>
+        </mtr>
+        <mtr>
+          <mtd>
+            <mn>0</mn>
+          </mtd>
+          <mtd>
+            <mn>0</mn>
+          </mtd>
+          <mtd>
+            <mn>1</mn>
+          </mtd>
+        </mtr>
+      </mtable>
+    </mpadded>
+    <mspace width="-4.981pt" />
+    <mo fence="true" lspace="0" rspace="0" symmetric="true">)</mo>
+  </mrow>
+  <mo lspace="0.278em" rspace="0.278em" tex:class="rel">=</mo>
+  <mrow tex:class="inner">
+    <mo fence="true" lspace="0" rspace="0" symmetric="true" tex:family="2">{</mo>
+    <mpadded lspace="+4.981pt" width="+9.963pt">
+      <mtable>
+        <mtr>
+          <mtd columnalign="left">
+            <mn>1</mn>
+          </mtd>
+          <mtd columnalign="left">
+            <mtext>if&#160; 
+            <math xmlns:tex="http://typesetting.eu/2021/LuaMathML" xmlns="http://www.w3.org/1998/Math/MathML">
+              <mi tex:family="1">𝑎</mi>
+              <mo lspace="0.278em" rspace="0.278em" tex:class="rel">=</mo>
+              <mi tex:family="1">𝑏</mi>
+            </math></mtext>
+          </mtd>
+        </mtr>
+        <mtr>
+          <mtd columnalign="left">
+            <mn>2</mn>
+          </mtd>
+          <mtd columnalign="left">
+            <mtext>else</mtext>
+          </mtd>
+        </mtr>
+      </mtable>
+    </mpadded>
+    <mspace width="1.196pt" />
+  </mrow>
+</math>
+<math display="block" xmlns:tex="http://typesetting.eu/2021/LuaMathML" xmlns="http://www.w3.org/1998/Math/MathML">
+  <mi tex:family="1">𝑥</mi>
+  <mo lspace="0.278em" rspace="0.278em" tex:class="rel">=</mo>
+  <mfrac>
+    <mrow>
+      <mo lspace="0" rspace="0.222em" tex:class="bin" tex:family="2">−</mo>
+      <mi tex:family="1">𝑏</mi>
+      <mo lspace="0.222em" rspace="0.222em" tex:class="bin" tex:family="2">±</mo>
+      <msqrt>
+        <mrow>
+          <msup>
+            <mi tex:family="1">𝑏</mi>
+            <mn>2</mn>
+          </msup>
+          <mo lspace="0.222em" rspace="0.222em" tex:class="bin" tex:family="2">−</mo>
+          <mn>4</mn>
+          <mi tex:family="1">𝑎</mi>
+          <mi tex:family="1">𝑐</mi>
+        </mrow>
+      </msqrt>
+    </mrow>
+    <mrow>
+      <mn>2</mn>
+      <mi tex:family="1">𝑎</mi>
+    </mrow>
+  </mfrac>
+  <mo lspace="0" rspace="0" tex:class="ord" tex:family="1">.</mo>
+</math>
+<math xmlns:tex="http://typesetting.eu/2021/LuaMathML" xmlns="http://www.w3.org/1998/Math/MathML">
+  <mi tex:family="1">𝑏</mi>
+</math>
+<math display="block" xmlns:tex="http://typesetting.eu/2021/LuaMathML" xmlns="http://www.w3.org/1998/Math/MathML">
+  <munder>
+    <mo lspace="0" movablelimits="true" rspace="0.167em" tex:class="opdisplaylimits" tex:family="3">∑</mo>
+    <mi tex:family="1">𝑎</mi>
+  </munder>
+  <munder>
+    <mi tex:family="1">𝑐</mi>
+    <mo>_</mo>
+  </munder>
+  <mover>
+    <mi tex:family="1">𝑏</mi>
+    <mo stretchy="false">_</mo>
+  </mover>
+  <msup>
+    <mi tex:family="1">𝑐</mi>
+    <mi mathvariant="normal" tex:family="2">′</mi>
+  </msup>
+</math>
+<math xmlns:tex="http://typesetting.eu/2021/LuaMathML" xmlns="http://www.w3.org/1998/Math/MathML">
+  <mrow tex:class="opnolimits">
+    <mi mathvariant="normal">s</mi>
+    <mi mathvariant="normal">i</mi>
+    <mi mathvariant="normal">n</mi>
+  </mrow>
+  <mo lspace="0" rspace="0" stretchy="false" tex:class="open">(</mo>
+  <mi tex:family="1">𝑥</mi>
+  <mo lspace="0" rspace="0" stretchy="false" tex:class="close">)</mo>
+  <mo lspace="0.222em" rspace="0.222em" tex:class="bin" tex:family="2">−</mo>
+  <mrow tex:class="opnolimits">
+    <mi mathvariant="normal">s</mi>
+    <mi mathvariant="normal">i</mi>
+    <mi mathvariant="normal">n</mi>
+  </mrow>
+  <mo lspace="0" rspace="0" stretchy="false" tex:class="open">(</mo>
+  <mi tex:family="1">𝑥</mi>
+  <mo lspace="0.222em" rspace="0.222em" tex:class="bin">+</mo>
+  <mn>2</mn>
+  <mi tex:family="1">𝜋</mi>
+  <mo lspace="0" rspace="0" stretchy="false" tex:class="close">)</mo>
+  <mo lspace="0.278em" rspace="0.278em" tex:class="rel">=</mo>
+  <mn>0</mn>
+</math>
diff --git a/testfiles-lua/cases.mlt b/testfiles-lua/cases.mlt
new file mode 100644
index 0000000..a0bfb14
--- /dev/null
+++ b/testfiles-lua/cases.mlt
@@ -0,0 +1,43 @@
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{
+  uncompress,
+  pdfversion = 2.0,
+}
+\documentclass{article}
+\usepackage[l3build]{luamml-demo}
+\usepackage{tagpdf}
+\tagpdfsetup{
+  activate-all,
+  interwordspace=true,
+}
+
+\begin{document}
+\tagstructbegin{tag=Document}
+\LuaMMLTagAF{} {
+\[
+  \left(\begin{matrix}
+    1 & 0 & 0 \\
+    0 & 1 & 0 \\
+    0 & 0 & 1
+  \end{matrix}\right)
+  =
+  \begin{cases}
+    1 & \mbox{if $a=b$}\\
+    2 & \mbox{else}
+  \end{cases}
+\]
+}
+\LuaMMLTagAF{} {
+\[
+  x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}.
+\]
+}
+\LuaMMLTagAF{} {
+\[
+  \sum_a\underline c\dot bc'
+\]
+}
+
+Es gilt \LuaMMLTagAF{}{$\sin(x)-\sin(x+2\pi)=0$}.
+\tagstructend
+\end{document}
diff --git a/testfiles-lua/test_xml.mlt b/testfiles-lua/test_xml.mlt
index a732ade..3c72240 100644
--- a/testfiles-lua/test_xml.mlt
+++ b/testfiles-lua/test_xml.mlt
@@ -24,8 +24,8 @@
   \end{pmatrix}
   =
   \begin{cases}
-    1 & $if $a=b\\
-    2 & $else$
+    1 & \text{if $a=b$}\\
+    2 & \text{else}
   \end{cases}
 \]
 }