improved creation of temporary database-directory (check permissions)
fixed empty-data bug and added tests