Change debugoutput to be configurable.
add more tests