added tests, fixed function conversion bug