Added tests and fixes to pass it