update code and tests