Added all fns and tests for ch2.