Added tests and function