This would help us investigate issues like https://github.com/flutter/flutter/issues/64781
Removes global variables and adds unit tests that can be copied for #65118