adding missing test and rewriting after code review