refactorings, bugfixes and additional testcases for client -> 100% line
coverage