Change algorithm for testing lock to see if it is owned by a session