Added functionality and tests for injectivity and surjectivity of functions