webtest cleanup and code improvement

webtest cleanups and code improvement