fixed message counter to be windowState aware

tests included