Update code and tests