General improvements and refactor. Now using pipping function call. Added CLI test cases