Fixed "already disposed" error in tests.