Consolidate NodeController.lock() into one method

It can be used for locking, unlocking, or checking lock status. Also add
more tests.