Copy code from service_identity as base

Mostly 1:1 copy except for:

- using the stdlib's unittest modules
- fixing the import
More meaningful coverage output