Detect invalid transation segments as part of the integration tests
Docstrings cleanups

Apply styleguide conventions.
Cleanup: Wrap if conditions
Cleanup: If it is True there is no need to check if it is True
Cleanups: Apply styleguide conventions for comments
Cleanup: Use print as function
Cleanup: Use implicit line continuation

It is cleaner that the backslash.
Cleanups: Cleaner way to set dictionaries
Minor globals cleanup

Make clear how many globals there are, and make them to appear at the
top of the code block.
Cleanups: Just shorten code
Cleanup: More readable way to generate the results HTML page
Cleanup: Search object should know how to display its search terms

Also the use of properties allows us to have a cleaner code.
Cleanup: Search object should know if it has an invalid search term
SQL cleanup

Use uppercase, span several lines to improve readability, use
implicit line continuation, invert quoting to avoid escaping.
Cleanup: Invert quoting to avoid escaping
Cleanups: Indents, whitespace and long lines wrap
Cleanup: Remove unnecessary function
Embedded HTML cleanups to improve readability

* Move template context retrieval to the top of the code block,
* Use format() to avoid mixing string with variables,
* Use implicit line continuation instead of endlessly concatenating strings,
* Use print as a function.

This a previous step to strip out the HTML into proper external templates.