Implements function CLI and adds tests