clean and split out examples

Clean up the implementation / naming. Encapsulate into more of a
module. Split out example tests