Convert example code to unittest