Parakeet test cases

A lot of bug fixes due to a test from parakeet, that even parakeet does not pass :-)