Set up associations properly and added tests