PEP-8 fixes for pages API.
Pull extract_payload_from_request out of expose_api.

Needs to be used in new version of API decorator and resulted in too much nesting in there the way it was.
Introduce new generation of API decorator...

Add improved error handling. Introduce error code.

Use new decorator with tested methods in histories API.
Add pages test cases, TODO fix these up.