I'd really prefer to moving these helpers out of this function and making them private (preface with an underscore).  I find it hard to read functions that contain internal functions.  For really short functions, like `click_link`, you can use `lambda` to define the function succinctly.