Added tests.
Changed the implementation of this one function.