add test for bug #4165
refactor test to reuse LDAP step
fix pep8 warnings
Merge branch '4165_ldap_hash-rebased'