reduced multiplications & fixed unit test