set the returnUri based on the URI that requests the Api, fix some bugs in Client, update test