avoid multiple norm calculations
correct norm calculation error
fix test warnings