Fix timeout function issue closing thread immaturely
Add ability to retry if phantomjs crash