Added offset to the matrix and added tests