Better is ElasticSearch ready check

When checking if ElasticSearch is ready make sure the results or for the
correct build_uuid.

Also fix the sleep waiting for ElasticSearch to finish processing the
related files.