Fix test cases / bugs