Remove function from global scope, and add unit tests