adding client basic and digest authentication + code cleanup