the reason the s4 uses the st4's engine is because the heads are shorter than the "regular" 916 motor. same reasoning why the new s4R uses (mostly) the same motor as the st4S. head clearance. that said, i don't know enough about the dimmensions of the testastretta head. if it can clear the bottom of the gastank, and you don't have wheel/head contact if your forks bottom out, it'll fit!!!
but as chris mentioned, there's the need for a new swingarm, new exhaust, relocating the battery, rethinking the airbox, etc...
PLEASE contact me on where you found this motor!! if chris has "dibs" if you don't want to go through with this awesome (but rather involved) project, i'd love to have a line on a super-cheap motor! (this is assuming it's in good running condition?!)....
cheers.