Minor refactoring; improvings in test