py: Factor out static/class method unwrapping code; add tests.
Add more tests.