fixed pull request review remarks and minor style consistency and test improvements.