Fix references
Make sure to avoid NRE in tests
Fix compilation error
Fix a failing test. When we do HEAD request for the static endpoint, we need to return the Content-Length with the attachment size.