Add locality constraint and tests