__index__ and __newindex__ can leak a tensor if it reports a lua error. This change only fixes leaks that occur during the tests.