Fixes errors found in unit testing