am ddafcf82: Merge "Fix bugs and add tests"

* commit 'ddafcf82dcfa0f978bd7fe8b658ace7671d9d8d7':
  Fix bugs and add tests