Fix TLS SNI, and add regression test cases