[misc] Improved test coverage and minor code style changes