Fix image URL encoding and add tests

- Fix encoding add some tests (56151978)
- Add test for link aliases (694c7b3c)