Fix malformed URLs and update test cases