[TEST] LoggingListener to restore the initial logger levels after any modification

Recent changes made to LoggingListener and pushed with #8820 caused the original logger levels not to be reset after modifications, as the new state was saved for restore instead of the previous one.

Added unit tests for LoggingListener as well.