Bad firefox - round 2

* Changed the `wait_for_ajax` detection, now it should be more reliable
* Fixed error in the advanced search test when it checked for presence of "clear" link but did not check its visibility