improved has_key, pep8 formatting
added doctests to testing