Sanitize the value of COLUMNS passed to terminal_width

For some weird reason COLUMNS is set with string on my box or at least python interprets it that way. That causes obvious problem when we try to subtract 37 from it ;-)

Additionally this PR fixes typo that would cause NameError and trivial pep8 issues