Added tests and modifications to support test where needed