improved tests, better logging