First-principles study of van der Waals interactions in MoS2 and MoO3