Added tests and implementation.