fixed inv, inv_sqrt, inv_square functions and added boundary tests