updated refactor. added tests. added chainworks script.