Simplify data access and add tests