fix various bugs in code
add completed unittests