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.