added new unitetest and fix db schema unique constraint