Move save method to cli, add tests