Also, I've seen tests so dumb that the better you understand a subject, the worse your chances are - because questions and answer templates are stupid/made by people who didn't master the subject, and if you understand things well, you're likely to write something that doesn't match the answer template.
This gets impressively more common at undergraduate level.
By way of example, typical advice is to concentrate on challenge, rather than quantity when teaching these students. Rather than giving them 50 problems of varying difficulty, just give them the 5 hardest ones. When assessing, rather than giving them lots of questions of varying difficulty (like a typical standard test), give them fewer questions, but make them require more thought.
As a parent, who helps in the classroom and observes quite a few children, I'd say that at least 10% of the children in my (typical) school would fall into the gifted category (by measured intelligence) and of those, probably more than half have some soft of learning difficulty. I'd also say that these children will be sold short by the standardised testing.
You don't believe you can identify mastery any other way, so you don't identify it any other way, and so you believe that testing is the only way to identify mastery. OK, but this circular logic is broken.
You could show subject mastery by creating anything, or performing anything, or explaining something verbally to someone else, or by earning money in that field. Writing answers to test questions is rarely a relevant skill and more often tests whether you were told about the exam's quirks rather than mastery of the subject.