add a default logger if none provided.
add some unit testing