Difference between 生前 and 死前
Yes, you are quite right that they both mean when someone was still alive. However, there is a clear distinction on the usage of the two words. 生前 is almost always used when someone is discussing about the life of a deceased. Example: 


  He did a lot of charity work when he was alive. 他生前做了很多善事。


死前, or more properly 临死之前, is almost always used when someone is discussing about a person prior to his death. Example:


  What did he said to you before he die? 他临死之前跟你说了什么？