refactor api on node and testing