Fix InMemoryAdapter queries after deleting from a join table

Fix the InMemoryAdapter so it properly cleans up the Detail/Master records on delete.
Added a test for the scenario.