Make the filterselect directive more testable by splitting the link and controller function, and add tests