refactored with log control
starting to improve tests