fix pretty print

Fixes #533

- includes tests