another refactoring

use esprima to write tests now