Fixed race condition in test.c

- Added ol_close_save function that will save the DB to disk before
  freeing and closing.

- Added check() macro to ol_close* functions.