Replace the NameError handling in tests._common