several fixes and improvements, added a test_harness