https://kondrat.atlassian.net/browse/RPS-7 core logic with test