fixed db compare bug
added tests and references