Fixed/added test target. Added initial test. Fixed a couple of bugs that discovered.