Implements #710. Adding new unit tests.