Fix multiple issues with the keystore grant mechanism am: af7783f735  -s ours
am: 86bd788446  -s ours

Change-Id: I7f748e9c7c716fa2fd2d8499d94a0d97b3d869cb