Clean up of src and test code.
Added more safeguards to unit test run script.