api: include-total should be a boolean
api: Reduce metric() to a single line.
Actually add package.py.

This should have been part of 8676e6900465e2f69f960966025f7760477af6a9.
tests: Do some serious work.

Took some doing but BaseAPI is now fully tested, found a few bugs along
the way too.