Gallery tests - wait for js to have loaded rather than HTML

The wait (for gallery_items) in these tests was being fooled by the html cache and the number of images from the previous test. If you watch the test closely the app loads showing the number of images from the last test, repaints and then shows the amount of images expected for this test.

The `files` javascript array will always initialize as 0 (unlike the cache) thus waiting for the javascript array to represent the amount of images is more reliable.

A long term fix will be to delete the cache upon the restart.

It is more apparent with more images as it takes longer for the gallery app to repaint and initialize.

I have tested this on run_adhoc_tests.