added selftest, cosmetic output fixes