refactor tests and change logging api