Preliminary unit tested Contract=>SG mapping code