Completed code and test