Improve the testability of the selection directive by moving the link initialization to a controller function and add appropriate tests