Add a few more cases to set-default test
Refactor relink into smaller pieces and add tests