test: some code style, optimizations, and other tweaks.