few more edge cases and fixed some tests