Fixed phantomjs test failures and conformed to c89 all-vars-at-beginning-of-function codestyle.