refactor tests and add tests for links