Adding having functionality and tests