ISPN-2786 Clear marshalling thread local

* Created a test that can detect thread local leaks with different
configurations.