code test ref: http://qiita.com/sugarrina/items/d7f6b20d1df84743f5ff