Tear down tests that modify the value of Thread.current
Create class CurrentRequestId
Replace Thread.current calls by CurrentRequestId object.
Move middleware configuration to environments.