Increased test coverage and introduced scala mock library.

This commit includes a lot of bug fixes related to testing cleanup