More fixes and tls test

Some more fixes, and a basic test of TLS connections of the XMPP servers that the app recommends.  There is more work on the tests in my fork, but that work is interwoven with some changes that might break things, and can wait until we get a stable release out.