add tests and fix rounding