rewrite unit tests with mock object and testing all flow instead of only one function