Added unit tests and test application minor business refactor (some refactor and cleanup remain)