Avoid unnecessary `KeyError`'s while testing.
Merge pull request #7855 from s0undt3ch/develop

Avoid unnecessary `KeyError`'s while testing.