gkeyldap refactoring

Summary:
1) move file operations in a different file
2) split code into reusable functions
3) improvements in docstrings and code