Fixes bug #1709, pthread tests fixes for CMake (Thanks Scott Percival!)