Completed testsuite for previous commit, fixed exposed bugs in code and tests.