fix bugs, change to yargs, refactor tests