add tests and fix issues where null values throw errors