add rspec tests and improve associations