found the (cli) off-by-one error, fixes #3
added tests, fixes #2