Add tests for links and better test code