add null check for certificate
add constant string
construct api call patterns, add logging
change unit test code