Refactor lib to use gulp streams. Improve tests