Put keychain lock/unlock (Mac) in dedicated functions for reuse

Change-Id: Iecea8860c80d6234d1849152650bf708e5efcbad
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>