Cleaned up sample, moved messy test stuff to separate class