[js] Refactor setup and use casperjs for testing