Fix tests

Empty spaces at the end of these lines made them fail
Fix for rails4
Add the second_id used in HABTM join tables