Add various functions and tests