Also this logic wont work when the last call was made as user2 and the current call is being made as current user. You will match this and determine that no switching is required. 

I think it will be easier to read and understand the code if instead of doing this we just add a login command as the first command we run in the base test class. So by default every test class has current users kerberos credentials. Then the test that wants to switch changes the user and then makes the call. Then in the teardown it switches to the current user.