improve database cleaning and fix remaining tests