Fixed Gem Spec, Added test and  cleaned up code.

This should have been more than one commit, but somehow I didn't check it in.