refactor stats logger
speed-up improvements for tests