I have the same problem (Redmi Note 4).
From what I've gathered, you cannot pass the CTS test with any other ROM than stable, unrooted with locked bootloader. However, most ROMs (including weekly Xiaomi.eu) pass the "Basic integrity" test, which is sufficient for Super Mario Run, etc.
Magisk...