Add and use createSession function.
Refactor/consolidate tls test code.

- WIP.