Loss functions : minor changes and unittests