Proper refactorization of the new Unit tests
Small optimizations