Firstly the pytroch version of VAE works fine.
Regarding different loss here is some of the possibilities

Different Batch Sizes in test vs train
Different classes you might generate from VAE sample during testing and training.