fixed a bug in, and added a unit test for, the shaddow_methods_while method