Fixed js for capybara scripts to work in headless env. Fixed #21