Fixed variable name error and added tests.