added tests and fixes for widget destruction