I asked Beta marine for a quote on engine replacement for our MD22 back in 2015 and they quoted me a 60HP engine (too big, 50 HP is plenty for the 40 Ocean) including their saildrive for £8'800, not including labour or anything else, so adjusting for inflation, 10-11k is probably on the low side unless you're doing it all yourself (and even then you'll have costs for haulout, crane, propeller, etc.)
This was based on seeing a bit of scary looking rust on the first viewing, which was caused by lack of maintenance from a leaky impeller pump, which turned out to be an easy fix and the rust superficial. Our MD22 has proven to be very reliable and made relatively few problems (exhaust elbow connector is a regular item, although now have a stainless one instead and once the PCV valve seized up). Heat exchanger looks good and I feed it genuine Volvo coolant with all the right additives to protect the precious cast aluminium, which seems to keep it happy.