Changed tests to reflect new code, found errors and repaired them.