Attach change handler before calling click()

There seems to be some race condition where the onchange sometimes
doesn't fire if we call click first.