better logging and tests