Add some metadata viewer tests

More to come. Also added some error handling into the metadata viewer,
fixing a crash when viewing a resource that has no uploaded file.