More work on locks

Also fixed a spurious failing test with the Topic.