update code and refector tests