code and tests for assignment 3