Merge "Fix app compaction bug and add tests." into rvc-dev am: 197709093a

Change-Id: Ib1bf66dc49b2a47e9bacdffd5bbeab2576c7c810