Ssl doublefree fix

Fixed a crash and an improper release
Added the basis for a unit test of the pairing material generation function