improve logging format and fix test_api unittests