Add unit tests and fix some false positives when checking for calls to register_widget()

We just added a base class for tests, which are based on a check: you can see a good example in 337c9ee282.