Sadly this is exactly what should be done in most contracts. (In a hypothetical alternate world where law worked more like OSS).
Of course it was unethical for them to do it without telling you and trying to charge you $5k for it, but law would be a heck of a lot cheaper if openness and code re-use were the default.