InvalidCastException when running Pipelines through unit tests

When running pipelines through a unit test we receive a random InvalidCastException coming from the MtsHelper

Test method ShoppingCartTest.UpdateTest1 threw exception: System.InvalidCastException: CoCreateInstance returned an unexpected type: expected Microsoft.CommerceServer.Internal.Orders.MtsHelper, received Microsoft.CommerceServer.Interop.PooledPipelineClass..

at System.EnterpriseServices.ServicedComponentProxyAttribute.CreateInstance(Type serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Type serverType, Object[] props, Boolean bNewObj)
at Microsoft.CommerceServer.Runtime.Orders.BasketGroupLoader.Load(String storedProcName, ListDictionary sqlParameters)
at Microsoft.CommerceServer.Runtime.Orders.OrderContext.GetBasket(Guid userId)
at CommerceServer.ShoppingCartSystem.Retrieve(Guid basketId)
at ShoppingCart.get_Basket()
at ShoppingCartTest.UpdateTest1()


When running under the normal web context everything is fine. When we re-run the test the problem goes away most of the time. I was someone could point out why the CreateInstance member would return an incorrect type?

Cheers,
Colin

[1234 byte] By [ColinBowern] at [2007-12-27]