How to reinitialize USB device?

Hi,
I am working on USB MSC device as PluggedDevice. https://github.com/markmal/MSD
(sorry the code is dirty with all kinds of debug, and the project is for PlatformIO/Eclipse, cannot be readily plugged into Arduino Studio)

The device is already working well.
I am running it through USB 2.0 CV verification testing (from usb.org).
My board successfully runs all Chapter 9 tests, and almost all MSC class tests.

However there are two issues, (may be caused by same problem).

  1. When I run "Case 1".."Case 13" tests one after another, it is successful for the very first test that run right after USB was plugged in. If I run same or another test right after that - it fails. I have to unplug and re-plug before running each test.
    The test log says: "Configuring device, set configuration = 0x1
    NOTE: It is expected the device has reset the data toggles on all Bulk endpoints after the above SetConfiguration call".
    It looks like after plugging the device in all endpoints are intact. But after first test they are left in some unusable state, ant it is expected that SET_CONFIGURATION should somehow clear it.
    I tried to call USBDevice.initEP(ep), I've added clearing of toggles of endpoints into that, clearing of stalls, set buffers counters to 0... all this does not help.

Question - how to reinitialize the USB device after SET_CONFIGURATION received to satisfy VC program?

  1. When I run "MSC Error Recovery Test", it runs all stall conditions successfully (both In and Out EPs are stalled), but in the end when VC issues "Test Unit Ready" to verify that the device has recovered, my device receives the first test command "CBW with invalid signature" it previously processed and correctly stalled in very beginning.

Also I see that there are 155 bytes available in Out pipe!
It looks like 5 CBWs, starting with the first one that was with invalid signature, were "remembered" by Host after I stalled them, and then were resent after MSC BOT Reset procedure completed.
In MSC BOT Reset procedure I clear stall of In and Out pipes both, and also tried to call initEP(), clear toggles and reset DoubleBuffer by setting all counters to 0, and even filled my Out buffers by 0s.

Question - how to reliably reinit the USB device that Host does not resend previously stalled CBWs?

If you need other details and/or my code, USB2CV logs, etc, please let me know.