Perform digest auth. according to RFC 2617.

Plus: added more unit tests, deleted unused test, some
refactoring.