does anyone sell bicycle trailers with brakes? I recently was involved in a wreck, because I was unable to slow my trailer. I am thinking about building a refit kit to install brakes on a trailer, but I don't want to reinvent the wheel.
I'm not aware of a commerically made one, I suspect the barrier is liability issues (and possible legal issues in some places). FWIW, the limits in Australia and New Zealand are the same as for any other vehicle, so the main restriction is that the trailer can't weigh more than the towing vehicle (note below). Other jurisdictions may have different rules.

Similar questions have been asked here before:
Hitch for a cart for braking
How to make a cargo trailer?

There are two basic ways to do this. Either have brakes on the trailer activated by a lever on the bike, or make some kind of inertia brake. Having a direct lever is very simple and intuitive for the rider, but you may find yourself limited by the length of brake cables you can buy (it's possible to buy the wire on a roll and fix the endcap yourself, but annoying).

An inertia brake is somewhat harder to build, but very effective. You need the towing arm to telescope somehow, so as the trailer pushes forward on the towing vehicle you have a small movement that you can use to apply brakes. I built a four wheel trailer that worked like this, and just used cheap V brakes on the trailer. That was sufficiently effective that I didn't bother with anything more complex. The drawbar was square tubing, with a bracket at the overlap holding one end of the brake cables.

The major caveat is that neither of those solves the real problem. Once you're sliding along the ground in front of the moving trailer, neither of those will help slow it down. In theory you could grab the brake lever and use that, but in practice you're likely to focus more on getting out from under the trailer.

My preferred solution is to use a bike with two rear wheels, either a four wheel bike or a delta trike. That way you're less likely to fall off it and you can have the trailer apply downforce between the rear wheels to help with traction.

(edit: note that the default limit is actually the unloaded mass of the towing vehicle that the total trailer mass has to be under, so most bike trailers fall well outside that limit. Here's a PDF. What saves the situation is that if the manufacturer specifies a limit that applies instead).