Encode uri components correctly
Fix test