Added unit test
(cherry picked from commit a87701ffbb88ea41a4714c79e2dcf0fed2b20c7d)
Fixed tests
(cherry picked from commit 023d349dbb46c45e4d1b10ecdb44c15679d0f6a9)