Refactory tests, use mock to replace flexmock