Moved functions to the correct locations; added more tests

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