Coding style and minor tests refactor