improve logging and testing