fixes type annotations for optionals, adds a few tests