It’s possible your child has Dyscalculia. My son is 11 almost 12 and has ADHD, Dyslexia and Dyscalculia. When he was diagnosed with Dyslexia and few years later diagnosed with ADHD, we took him to see a neuropsych specialist (non MD) who discovered while testing him, that he has a math disability. His symptoms include difficulty with sequencing, memorization of math facts and slower processing speed. Some of these characteristics overlap with ADHD and Dyslexia. Often times when a person is diagnosed with ADHD or a LD such as Dyslexia, it is common for them to also have executive function issues, memory processing issues, as well as Dyscalculia. Because your son is doing so well with other subjects, i suspect a math disability is possible. If he is just having difficulty with tests, maybe it is test anxiety. If he is diagnosed with a math disability, he can receive accommodations in the school to help him with math tests. It depends specifically what his math struggles are.
BTW–the specialist did not specifically say “dyscalculia” but said “math disability”. Not sure why they don’t specifically label with known diagnosis—possibly because she is not a physician.