More unit tests, some algorithm changes

More unit tests were added along with some minor changes to algorithm
code. Updated deprecated method names (failUnlessAlmostEqual) to
current ones (assertAlmostEqual).