More work on associations and refactoring
Fixed test