Fixes for TLS on OSX and more reliable test running