test examples and small refactorings