Added tests and fixed(?) #2