modify logging and add some test