Fixes to compilation issues.  Consistant use of hash_ref instead of dereferencing. Add test case.