make sure specs finish executing, send a meaningful return code

In trying to use this sample code in my own project, I ran into two problems that are fixed in this pull request:

* This sample code works fine for a small number of specs, but if you have many specs, the pageLoad event might fire before the specs are done running so phantomjs will exit before the specs finish. 

* I wanted to integrate this into a continuous integration process (in my case, Travis-CI). To do this I needed phantomjs to send a return code indicating success or failure. So I use a regular expression to find the number of failed specs reported and, if it's non-zero, then I return a non-zero return code.