Second attempt, this time with fixed tests. (cherry picked from commit 8a5101a2) Change-Id: I76703df5610510a7adaa6cfd562338a40966bef6