added new function to retrieve SNI from a buffer.
added more tests with code refactoring.