replace register_notify with a_block_until

using a context manager instead of a function ensures
we can still clean up the callback function even
if an exception is raised.