Unregister listeners in case of test exceptions.
Fixed Clang warning about using result of assignment.
Avoid name clashes on Windows when linking static libraries.