Code patch by Serhiy Storchaka
Patch import and initialization in SearchEngine to make testing easier. Improve docstrings, especially to clarify the double role of 'ok' parameters. Original patch by Phil Webster.