Some code and test cleanup

Signed-off-by: license2e <ilya@shindyapin.com>