restructuring datastore and adding tests