as per Marco Falke review suggestion.
and update code comments as per Python PEP 8 style guide.
Original tests by João Barbosa <joao.paulo.barbosa@gmail.com> Additional contribution by John Newbery <john@johnnewbery.com>