Refactored tls config copy method to make it more testable and added test