Fix algo typo and improve tests.

Fix #172 

/cc @felipekk