completed the function 'diagonal' and added tests