Code refactoring in tests.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>