added logging and some tests