Fix link_to logic messed up during refactoring

and add test for it so it won't happen again