Refactor generation of casperjs command