Locking robustness fixes

- Add required locks in tests (fixes #4084)
- Get required locks up-front in GUI updates and use a try_lock to skip when lock already held (fixes #4083)
- Add missing AssertLockHeld in ConnectBlock (missed this externally-callable function in #4058)