Minor code cleanup
Increase test coverage, refactorings