Detect and use a testing interface

This allows testing frameworks to hook into Pig and makes testing Pig handlers much simpler.