cleaned up test rig. more tests. fix bugs.