Removing duplicated test code for in-memory and mongo DAO impls. Also fixing some bugs in the in-memory implementations. Plus some minor test improvements.