fixed HABTM bug and updated tests