Refactor SSL Management, and add tests for https