add: some function definitions and tests.