Updated the walkReg method to accept a function as a parameter and
modified unit test.