Fix output, add tests, update docs