added more api test cases and ostensibly fixed foreignkey relationships in the api