[analyzer] Fix pthread lock tests so that the API comes from a system header.

...and verify that a global mutex in user code can be used without warnings.

Patch by Aleksei Sidorin!