refactoring: improve code and tests for PowerSpySensor