Fix for failing test and moved add/removeHeaderLink calls into functions