Refactored casperjs run time conditional