webtest cleanup and code improvement