Fix flapping test and improve logging

Ref. #604