Better test for OSX build of test.
Don't create a subdirectory for test database.
Cleaned up cursor loops.