Fix parsing edge cases and added edge case tests