DAR-1184, small refactoring
DAR-1184, add type validation + small refactoring
DAR-1184, testing