Refactored to bring common test tool methods into a module of its own. Fixed some problems resulting from the above.