complete refactor. passing unit tests. mongodb data storage