Adding restoring counter to output.

Also fixing randomly failing test.