Added tests, discovered bug