cleaning up client and adding test cases

List of Issues this fixes on its way: