Numerical algorithm for moving-boundary fluid dynamics problems and its testing