I think you can refine your lesson a bit.
Expect the unexpected is a good mantra, but it doesn't do much good without some other components.
How long have you been driving or riding in freeway traffic? People do a lot of dumb things, but with experience and analysis, you can learn to expect some relatively common behaviors in certain situations. Expecting the unexpected is only part of the lesson. Analyzing situations and behaviors, and recognizing and preparing for likely scenarios will get you a lot farther. If you don't have a lot of freeway miles (I'd say at least 50k, in whatever vehicle), some of the things can surprise you. But you'll hear experienced freeway travelers talk about near misses and how they "knew this guy was going to do such and such." The key is that the "unexpected" was not only expected, but accounted for and they were able to react accordingly in time. Learning those patterns comes from experience, though.
Usually, recognizing an erratic driver and putting more distance between them and yourself will greatly increase your odds of avoiding an incident with them. Bad/dangerous drivers give clues, like diving into an exit, or drifting and swerving in their lane, or slaloming through traffic. Our eyes pick up on the motion that doesn't fit with the expected flow. Once you pick up on a dangerous driver, you must monitor their behavior and take steps to distance yourself from them.
Also, parking lot drills on swerving would help. Or, you can practice by dodging objects like manholes or just dots in the road. Just don't go down doing it!
I mentioned target fixation, which is a constant battle for newer riders (I consider myself one). I can hear you verbally reacting to the situation, which indicates that you probably locked on to the car and hitting it was a foregone conclusion in your mind. Training yourself to rip your eyes away from the threat, and looking where you want to go instead and piloting the bike to go there will save your butt.