Fix bug in getNumVariables() and add test.