added tests for checking links go to the correct places and refactored