Added tests
(cherry-picked 830a610c7d9422889d2c276c611b1df4efecd931)