Actually release lock when exiting advisory_lock.

In version 1.0.1 the lock isn't released when `acquired = ''` — which is the common case!

I've added a test suite in order to write a regression test for this bug. It makes the pull request quite large but I hope it's helpful in the future.