refactored tests and used mock lib when required