Re-factored view model to make code more testable.