CIDEVMI-1181 TRHPH: Optimized code, added unit and performance tests

Also removed chloride wrapper function.

@s-pearce Ready to review and merge
@cwingard Ready for review and merge