Update to test case and variableref.java

I managed to leave out the one line in the test case which was required to test the bug. I have updated the test case and have reapplied by patch to the VariableRef class which fixes issue.