Made the lockserver work with ssh messaging.

ssh messaging re-invokes messaging commands on the suite host, resulting in  a second attempt to acquire a task lock (by the initial and re-invoked command). This change fixes the problem and tidies some task locking code.