Add function bodies and test cases