We can now have methods that release a locked in shared mode and acquire
it in exclusive mode or the other way around. The fix was just to
release the locks before acquiring them.
Also added a few test cases for non-generic unlock methods and removed
an unnecessary const_cast.
This was necessary to make sure we produce warnings of the kind releasing mutex '...' using exclusive access, expected shared access for both configurations.