better loggin, test and minor fixes