tests with mocking

@dbrgn can you please review as discussed. thx.