diff --git a/libmat2/office.py b/libmat2/office.py
index d067128da4be6f990c79a003dacdc810c0ebb05b..1a793b4a8e10b75aa8f3285258867c78db2a5fe2 100644
--- a/libmat2/office.py
+++ b/libmat2/office.py
@@ -525,7 +525,7 @@ class MSOfficeParser(ZipParser):
         # see: https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/mc-ignorable-attribute
         with open(full_path, 'rb') as f:
             text = f.read()
-            out = re.sub(b'mc:Ignorable="[^"]*"', b'', text, 1)
+            out = re.sub(b'mc:Ignorable="[^"]*"', b'', text, count=1)
         with open(full_path, 'wb') as f:
             f.write(out)
 
diff --git a/libmat2/pdf.py b/libmat2/pdf.py
index 2da21b5dac3fd6f752e07bf1897c63a85e6728f6..0672214db3cb8eb9128c1350e3e24e794a750b16 100644
--- a/libmat2/pdf.py
+++ b/libmat2/pdf.py
@@ -136,8 +136,8 @@ class PDFParser(abstract.AbstractParser):
         # It should(tm) be alright though, because cairo's output format
         # for metadata is fixed.
         with open(out_file, 'rb') as f:
-            out = re.sub(rb'<<[\s\n]*/Producer.*?>>', b' << >>', f.read(), 0,
-                         re.DOTALL | re.IGNORECASE)
+            out = re.sub(rb'<<[\s\n]*/Producer.*?>>', b' << >>', f.read(),
+                         count=0, flags=re.DOTALL | re.IGNORECASE)
         with open(out_file, 'wb') as f:
             f.write(out)
 
diff --git a/libmat2/web.py b/libmat2/web.py
index e33288e35a44008859679d61b8a38222d6cb5a3e..9bbd221881f3248168162751696f24213d0ab5f8 100644
--- a/libmat2/web.py
+++ b/libmat2/web.py
@@ -20,7 +20,7 @@ class CSSParser(abstract.AbstractParser):
                 content = f.read()
             except UnicodeDecodeError:  # pragma: no cover
                 raise ValueError
-            cleaned = re.sub(r'/\*.*?\*/', '', content, 0, self.flags)
+            cleaned = re.sub(r'/\*.*?\*/', '', content, count=0, flags=self.flags)
         with open(self.output_filename, 'w', encoding='utf-8') as f:
             f.write(cleaned)
         return True
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py
index 78550627ac6882e2431d93a73016e6e1b036de02..19252011f3bd0af678c863680008e800b1e18dff 100644
--- a/tests/test_libmat2.py
+++ b/tests/test_libmat2.py
@@ -508,8 +508,11 @@ class TestCleaning(unittest.TestCase):
                 'TrackID': 1,
                 'TrackLayer': 0,
                 'TransferCharacteristics': 'BT.709',
-                'VideoFullRangeFlag': 0,
+                'VideoFullRangeFlag': 'Limited',
             },
+            'extra_expected_meta': {
+                'VideoFullRangeFlag': 0,
+             }
         },{
             'name': 'wmv',
             'ffmpeg': 1,
@@ -522,7 +525,10 @@ class TestCleaning(unittest.TestCase):
             'name': 'heic',
             'parser': images.HEICParser,
             'meta': {},
-            'expected_meta': {},
+            'expected_meta': {
+                'ExifByteOrder': 'Big-endian (Motorola, MM)',
+                'Warning': 'Bad IFD0 directory',
+            },
         }
         ]
 
@@ -558,7 +564,12 @@ class TestCleaning(unittest.TestCase):
                 if meta:
                     for k, v in p2.get_meta().items():
                         self.assertIn(k, case['expected_meta'], '"%s" is not in "%s" (%s)' % (k, case['expected_meta'], case['name']))
-                        self.assertIn(str(case['expected_meta'][k]), str(v))
+                        if str(case['expected_meta'][k]) in str(v):
+                            continue
+                        if 'extra_expected_meta' in case and k in case['extra_expected_meta']:
+                            if str(case['extra_expected_meta'][k]) in str(v):
+                                continue
+                        self.assertTrue(False, "got a different value (%s) than excepted (%s) for %s" % (str(v), meta, k))
                 self.assertTrue(p2.remove_all())
 
                 os.remove(target)