chore: unit tests, code optimizations