Add test for readDir primop
Add readDir primop
Remove some duplicate code