Common API code and tests