There's no way to avoid the trolley problem as long as you're developing self-driving cars. You
can wilfully ignore the trolley problem and let the algorithm do whatever it does, but that doesn't make it go away.
And I would dispute that emergency braking suddenly while being tailgated is less "crazy shit" than swerving into the next lane where your presence will, with an exceptional degree of confidence, be immediately detected and compensated for.
To clarify, the scenario in my mind is one that would be bold but not dangerous; something a good human driver might do with 360° situational awareness. In this instance it could be the difference between swerving to miss an obstacle or a multiple-car collision — even if your self driving car can stop in time, the tailgater is likely to slam into you, which in turn slams you into the obstacle.
Or to change the situation a bit, if the "tailgating" car happened to be a self driving car with an aggressive profile, that could swing the decision back towards braking. Point is, knowing that a car is being driven by a computer can aid decisions made by other cars.